- cmdLine << "--index" << pathToLocal(QDir::toNativeSeparators(indexFile), true, false);
- cmdLine << pathToLocal(QDir::toNativeSeparators(m_sourceFileName));
- }
-
- return cmdLine;
-}
-
-unsigned int EncodeThread::checkVersionX264(bool x64, bool &modified)
-{
- QProcess process;
- QStringList cmdLine = QStringList() << "--version";
-
- log("Creating process:");
- if(!startProcess(process, QString("%1/%2.exe").arg(m_binDir, x64 ? "x264_x64" : "x264"), cmdLine))
- {
- return false;;
- }
-
- QRegExp regExpVersion("\\bx264\\s(\\d)\\.(\\d+)\\.(\\d+)\\s([a-f0-9]{7})", Qt::CaseInsensitive);
- QRegExp regExpVersionMod("\\bx264 (\\d)\\.(\\d+)\\.(\\d+)", Qt::CaseInsensitive);
-
- bool bTimeout = false;
- bool bAborted = false;
-
- unsigned int revision = UINT_MAX;
- unsigned int coreVers = UINT_MAX;
- modified = false;
-
- while(process.state() != QProcess::NotRunning)
- {
- if(m_abort)
- {
- process.kill();
- bAborted = true;
- break;
- }
- if(!process.waitForReadyRead())
- {
- if(process.state() == QProcess::Running)
- {
- process.kill();
- qWarning("x264 process timed out <-- killing!");
- log("\nPROCESS TIMEOUT !!!");
- bTimeout = true;
- break;
- }
- }
- while(process.bytesAvailable() > 0)
- {
- QList<QByteArray> lines = process.readLine().split('\r');
- while(!lines.isEmpty())
- {
- QString text = QString::fromUtf8(lines.takeFirst().constData()).simplified();
- int offset = -1;
- if((offset = regExpVersion.lastIndexIn(text)) >= 0)
- {
- bool ok1 = false, ok2 = false;
- unsigned int temp1 = regExpVersion.cap(2).toUInt(&ok1);
- unsigned int temp2 = regExpVersion.cap(3).toUInt(&ok2);
- if(ok1) coreVers = temp1;
- if(ok2) revision = temp2;
- }
- else if((offset = regExpVersionMod.lastIndexIn(text)) >= 0)
- {
- bool ok1 = false, ok2 = false;
- unsigned int temp1 = regExpVersionMod.cap(2).toUInt(&ok1);
- unsigned int temp2 = regExpVersionMod.cap(3).toUInt(&ok2);
- if(ok1) coreVers = temp1;
- if(ok2) revision = temp2;
- modified = true;
- }
- if(!text.isEmpty())
- {
- log(text);
- }
- }
- }
- }
-
- process.waitForFinished();
- if(process.state() != QProcess::NotRunning)
- {
- process.kill();
- process.waitForFinished(-1);
- }
-
- if(bTimeout || bAborted || process.exitCode() != EXIT_SUCCESS)
- {
- if(!(bTimeout || bAborted))
- {
- log(tr("\nPROCESS EXITED WITH ERROR CODE: %1").arg(QString::number(process.exitCode())));
- }
- return UINT_MAX;
- }
-
- if((revision == UINT_MAX) || (coreVers == UINT_MAX))
- {
- log(tr("\nFAILED TO DETERMINE X264 VERSION !!!"));
- return UINT_MAX;
- }
-
- return (coreVers * REV_MULT) + (revision % REV_MULT);
-}
-
-unsigned int EncodeThread::checkVersionAvs2yuv(bool x64)
-{
- QProcess process;
-
- log("\nCreating process:");
- if(!startProcess(process, QString("%1/%2.exe").arg(m_binDir, x64 ? "avs2yuv_x64" : "avs2yuv"), QStringList()))
- {
- return false;;
- }
-
- QRegExp regExpVersionMod("\\bAvs2YUV (\\d+).(\\d+)bm(\\d)\\b", Qt::CaseInsensitive);
- QRegExp regExpVersionOld("\\bAvs2YUV (\\d+).(\\d+)\\b", Qt::CaseInsensitive);
-
- bool bTimeout = false;
- bool bAborted = false;
-
- unsigned int ver_maj = UINT_MAX;
- unsigned int ver_min = UINT_MAX;
- unsigned int ver_mod = 0;
-
- while(process.state() != QProcess::NotRunning)
- {
- if(m_abort)
- {
- process.kill();
- bAborted = true;
- break;
- }
- if(!process.waitForReadyRead())
- {
- if(process.state() == QProcess::Running)
- {
- process.kill();
- qWarning("Avs2YUV process timed out <-- killing!");
- log("\nPROCESS TIMEOUT !!!");
- bTimeout = true;
- break;
- }
- }
- while(process.bytesAvailable() > 0)
- {
- QList<QByteArray> lines = process.readLine().split('\r');
- while(!lines.isEmpty())
- {
- QString text = QString::fromUtf8(lines.takeFirst().constData()).simplified();
- int offset = -1;
- if((ver_maj == UINT_MAX) || (ver_min == UINT_MAX) || (ver_mod == UINT_MAX))
- {
- if(!text.isEmpty())
- {
- log(text);
- }
- }
- if((offset = regExpVersionMod.lastIndexIn(text)) >= 0)
- {
- bool ok1 = false, ok2 = false, ok3 = false;
- unsigned int temp1 = regExpVersionMod.cap(1).toUInt(&ok1);
- unsigned int temp2 = regExpVersionMod.cap(2).toUInt(&ok2);
- unsigned int temp3 = regExpVersionMod.cap(3).toUInt(&ok3);
- if(ok1) ver_maj = temp1;
- if(ok2) ver_min = temp2;
- if(ok3) ver_mod = temp3;
- }
- else if((offset = regExpVersionOld.lastIndexIn(text)) >= 0)
- {
- bool ok1 = false, ok2 = false;
- unsigned int temp1 = regExpVersionOld.cap(1).toUInt(&ok1);
- unsigned int temp2 = regExpVersionOld.cap(2).toUInt(&ok2);
- if(ok1) ver_maj = temp1;
- if(ok2) ver_min = temp2;
- }
- }
- }
- }
-
- process.waitForFinished();
- if(process.state() != QProcess::NotRunning)
- {
- process.kill();
- process.waitForFinished(-1);
- }
-
- if(bTimeout || bAborted || ((process.exitCode() != EXIT_SUCCESS) && (process.exitCode() != 2)))
- {
- if(!(bTimeout || bAborted))
- {
- log(tr("\nPROCESS EXITED WITH ERROR CODE: %1").arg(QString::number(process.exitCode())));
- }
- return UINT_MAX;
- }
-
- if((ver_maj == UINT_MAX) || (ver_min == UINT_MAX))
- {
- log(tr("\nFAILED TO DETERMINE AVS2YUV VERSION !!!"));
- return UINT_MAX;
- }
-
- return (ver_maj * REV_MULT) + ((ver_min % REV_MULT) * 10) + (ver_mod % 10);
-}
-
-bool EncodeThread::checkProperties(bool x64, unsigned int &frames)
-{
- QProcess process;
-
- QStringList cmdLine = QStringList() << "-frames" << "1";
- cmdLine << pathToLocal(QDir::toNativeSeparators(m_sourceFileName)) << "NUL";
-
- log("Creating process:");
- if(!startProcess(process, QString("%1/%2.exe").arg(m_binDir, x64 ? "avs2yuv_x64" : "avs2yuv"), cmdLine))
- {
- return false;;
- }
-
- QRegExp regExpInt(": (\\d+)x(\\d+), (\\d+) fps, (\\d+) frames");
- QRegExp regExpFrc(": (\\d+)x(\\d+), (\\d+)/(\\d+) fps, (\\d+) frames");
-
- QTextCodec *localCodec = QTextCodec::codecForName("System");
-
- bool bTimeout = false;
- bool bAborted = false;
-
- frames = 0;
-
- unsigned int fpsNom = 0;
- unsigned int fpsDen = 0;
- unsigned int fSizeW = 0;
- unsigned int fSizeH = 0;
-
- while(process.state() != QProcess::NotRunning)
- {
- if(m_abort)
- {
- process.kill();
- bAborted = true;
- break;
- }
- if(!process.waitForReadyRead())
- {
- if(process.state() == QProcess::Running)
- {
- process.kill();
- qWarning("Avs2YUV process timed out <-- killing!");
- log("\nPROCESS TIMEOUT !!!");
- bTimeout = true;
- break;
- }
- }
- while(process.bytesAvailable() > 0)
- {
- QList<QByteArray> lines = process.readLine().split('\r');
- while(!lines.isEmpty())
- {
- QString text = localCodec->toUnicode(lines.takeFirst().constData()).simplified();
- int offset = -1;
- if((offset = regExpInt.lastIndexIn(text)) >= 0)
- {
- bool ok1 = false, ok2 = false;
- bool ok3 = false, ok4 = false;
- unsigned int temp1 = regExpInt.cap(1).toUInt(&ok1);
- unsigned int temp2 = regExpInt.cap(2).toUInt(&ok2);
- unsigned int temp3 = regExpInt.cap(3).toUInt(&ok3);
- unsigned int temp4 = regExpInt.cap(4).toUInt(&ok4);
- if(ok1) fSizeW = temp1;
- if(ok2) fSizeH = temp2;
- if(ok3) fpsNom = temp3;
- if(ok4) frames = temp4;
- }
- else if((offset = regExpFrc.lastIndexIn(text)) >= 0)
- {
- bool ok1 = false, ok2 = false;
- bool ok3 = false, ok4 = false, ok5 = false;
- unsigned int temp1 = regExpFrc.cap(1).toUInt(&ok1);
- unsigned int temp2 = regExpFrc.cap(2).toUInt(&ok2);
- unsigned int temp3 = regExpFrc.cap(3).toUInt(&ok3);
- unsigned int temp4 = regExpFrc.cap(4).toUInt(&ok4);
- unsigned int temp5 = regExpFrc.cap(5).toUInt(&ok5);
- if(ok1) fSizeW = temp1;
- if(ok2) fSizeH = temp2;
- if(ok3) fpsNom = temp3;
- if(ok4) fpsDen = temp4;
- if(ok5) frames = temp5;
- }
- if(!text.isEmpty())
- {
- log(text);
- }
- if(text.contains("failed to load avisynth.dll", Qt::CaseInsensitive))
- {
- log(tr("\nWarning: It seems that %1-Bit Avisynth is not currently installed !!!").arg(x64 ? "64" : "32"));
- }
- }
- }
- }
-
- process.waitForFinished();
- if(process.state() != QProcess::NotRunning)
- {
- process.kill();
- process.waitForFinished(-1);