我已经添加了第二个答案,因为它可以作为 SMPlayer中的常规播放列表使用,在这里为了清楚起见最好。
我已经通过播放列表完美地运行了...
此方法需要重新编译SMPlayer,并需要一种特定的文件命名方法...仅修改SMPlayer源中的一个函数,并将3个标头添加到同一单个源文件中...我已经smplayer_0.6.8
为Lucid 进行了编译。 。Maveric和Meerkat使用smplayer_0.6.9
..更高版本中的一行是不同的,但这并不会影响任何事情...这是修改后的函数和标头smplayer_0.6.8
顺便说一句,我以前的答案中的“ zenity”对话框仍然用于捕获开始时间和结束时间...
提醒 -以下源段适用于smplayer_0.6.8
...要修改的文件是:../smplayer-0.6.9/src/findsubtitles/osparser.cpp
...新段与'0.6.8'和'0.6.9'相同,但原始段相差一行(非常接近结束;就在最后return hexhash;
)
将这第一行代码添加到现有#include
标题的 正下方
// ====================
// fred mod begin block
#include <QFileInfo>
#include <QRegExp>
#include <QSettings>
#include "paths.h"
// fred mod end block
// ==================
这是修改后的功能
QString OSParser::calculateHash(QString filename) {
QFile file(filename);
if (!file.exists()) {
qWarning("OSParser:calculateHash: error hashing file. File doesn't exist.");
return QString();
}
file.open(QIODevice::ReadOnly);
QDataStream in(&file);
in.setByteOrder(QDataStream::LittleEndian);
quint64 size=file.size ();
quint64 hash=size;
quint64 a;
for(int i = 0; i < 8192; i++) {
in >> a ; hash += a;
};
file.seek(size-65536);
for(int i = 0; i < 8192; i++) {
in >> a ; hash += a;
};
// =====================================================================
// fred mod begin block
//
// A mod to enable unique smplayer .ini files to be created for
// content-identical media files whose file-names match
// a specific pattern based on two timestamps.
// This is the naming pattern:
//
// name.[00:11:22].[33.44.55].mkv
//
// The two time stamps indicate the start and end points of a
// clip to be played according to settings in the unique .ini
//
// The so named files can be, and typically will be, soft (or hard) links.
// The "original" file can also named in this manner, if you like,
// but that would make the "original" start playing as a clip,
// NOTE: soft links become invalid when you rename the original file.
//
// Note: For this system to work, you need to enable the following:
// In SMPlayer's GUI, open the Options dialog...
// In the "General" tab... "Media settings"...
// enable: 〼 "Remember settings for all files (audio track, subtitles...)"
// "Remember time position" can be 'on' or 'off'; it is optional1
// but it is disabled for these clips.
// "Store setings in" must be: "multiple ini files"
//
QFileInfo fi(filename);
QString name = fi.fileName();
//
// ===================================================================
// This RegExp expects a name-part,
// followed by 2 .[timestamps] (Begin-time and End-time)
// followed by a .extension
//
// .[ Begin ].[ End ]
// eg. name.[00:11:22].[33.44.55].mkv
//
// Note: The delimiter between each numeric value can be any non-numeric character.
// The leading dot '.' and square brackets '[]' must be as shown
// HH, MM, and SS must each be 2 valid time-digits
//
QRegExp rx("^.+" // NAME
"\\.\\[([0-9][0-9])[^0-9]" // .[HH.
"([0-5][0-9])[^0-9]" // mm.
"([0-5][0-9])\\]" // ss]
"\\.\\[([0-9][0-9])[^0-9]" // .[HH.
"([0-5][0-9])[^0-9]" // mm.
"([0-5][0-9])\\]" // ss]
"\\.([^0-9]+)$"); // .EXTN
//
QString qstrIni;
rx.setPatternSyntax(QRegExp::RegExp);
if(rx.exactMatch(name)) {
bool ok;
QString qstrDlm(".");
QString qstrBegEnd = rx.cap(1) + rx.cap(2) + rx.cap(3)
+ rx.cap(4) + rx.cap(5) + rx.cap(6);
hash += qstrBegEnd.toLongLong(&ok,10); // The UNIQUE-FIER
//
quint32 quiBegSec=(rx.cap(1).toULong(&ok,10)*3600)
+(rx.cap(2).toULong(&ok,10)* 60)
+(rx.cap(3).toULong(&ok,10));
quint32 quiEndSec=(rx.cap(4).toULong(&ok,10)*3600)
+(rx.cap(5).toULong(&ok,10)* 60)
+(rx.cap(6).toULong(&ok,10));
quint32 quiDifSec=(quiEndSec-quiBegSec);
//
QString qstrBegIni = "-ss " + QString::number(quiBegSec);
QString qstrEndIni = "-endpos " + QString::number(quiDifSec);
qstrIni = qstrBegIni + " " + qstrEndIni;
}
// fred mod end block
// =====================================================================
// fred NOTE: the following 2 lines are a single line in smplayer-0.6.9
QString hexhash("");
hexhash.setNum(hash,16);
// =====================================================================
// fred mod begin block
if( !qstrIni.isEmpty() ) {
// ** The next code line is not ideal, but should be okay so long
// as SMPlayer's options are set to use Multiple .ini files.
// The literal "file_settings" is HARDCODED, as It wasnt' straight
// forward to get the value, The rest of the path was easily available
// without any significant mods, which "file_settings" would require.
// TODO: Check for Multiple .ini Option being enabled.
//
QString dir_settings = Paths::configPath() + "/file_settings";
QString fqfn_settings = dir_settings + "/" + hexhash[0] + "/" + hexhash + ".ini";
QSettings set(fqfn_settings, QSettings::IniFormat);
set.beginGroup("file_settings");
set.setValue( "starting_time", "0" );
set.setValue( "mplayer_additional_options", qstrIni );
}
// fred mod end block
// =====================================================================
return hexhash;
}
flag
问题上的按钮并要求将其迁移。