Update autoset ffmpeg path

This commit is contained in:
manongjohn 2021-03-13 18:39:35 -05:00 committed by manongjohn
parent 9776462747
commit 2c3d3bf045

View file

@ -21,87 +21,76 @@ Ffmpeg::Ffmpeg() {
Ffmpeg::~Ffmpeg() {} Ffmpeg::~Ffmpeg() {}
bool Ffmpeg::checkFfmpeg() { bool Ffmpeg::checkFfmpeg() {
// check the user defined path in preferences first QString exe = "ffmpeg";
QString path = Preferences::instance()->getFfmpegPath() + "/ffmpeg";
#if defined(_WIN32) #if defined(_WIN32)
path = path + ".exe"; exe = exe + ".exe";
#endif #endif
// check the user defined path in preferences first
QString path = Preferences::instance()->getFfmpegPath() + "/" + exe;
if (TSystem::doesExistFileOrLevel(TFilePath(path))) return true; if (TSystem::doesExistFileOrLevel(TFilePath(path))) return true;
// check the Tahoma root directory next // Let's try and autodetect the exe included with release
path = QDir::currentPath() + "/ffmpeg"; QStringList folderList;
#if defined(_WIN32)
path = path + ".exe"; folderList.append(".");
#endif folderList.append("./ffmpeg"); // ffmpeg folder
if (TSystem::doesExistFileOrLevel(TFilePath(path))) {
Preferences::instance()->setValue(ffmpegPath, QDir::currentPath());
return true;
}
#ifdef MACOSX #ifdef MACOSX
path = QDir::currentPath() + "/" + // Look inside app
QString::fromStdString(TEnv::getApplicationFileName()) + folderList.append("./" +
".app/ffmpeg/ffmpeg"; QString::fromStdString(TEnv::getApplicationFileName()) +
if (TSystem::doesExistFileOrLevel(TFilePath(path))) { ".app/ffmpeg"); // ffmpeg folder
Preferences::instance()->setValue( #elif defined LINUX
ffmpegPath, QDir::currentPath() + "/" + // Need to account for symbolic links
QString::fromStdString(TEnv::getApplicationFileName()) + folderList.append(TEnv::getWorkingDirectory().getQString() +
".app/ffmpeg/"); "/ffmpeg"); // ffmpeg folder
return true;
}
#endif #endif
#ifdef LINUX QString exePath = TSystem::findFileLocation(folderList, exe);
QString currentPath = TEnv::getWorkingDirectory().getQString();
path = currentPath + "/ffmpeg/ffmpeg"; if (!exePath.isEmpty()) {
if (TSystem::doesExistFileOrLevel(TFilePath(path))) { Preferences::instance()->setValue(ffmpegPath, exePath);
Preferences::instance()->setValue(ffmpegPath, currentPath + "/ffmpeg/");
return true; return true;
} }
#endif
// give up // give up
return false; return false;
} }
bool Ffmpeg::checkFfprobe() { bool Ffmpeg::checkFfprobe() {
// check the user defined path in preferences first QString exe = "ffprobe";
QString path = Preferences::instance()->getFfmpegPath() + "/ffprobe";
#if defined(_WIN32) #if defined(_WIN32)
path = path + ".exe"; exe = exe + ".exe";
#endif #endif
// check the user defined path in preferences first
QString path = Preferences::instance()->getFfmpegPath() + "/" + exe;
if (TSystem::doesExistFileOrLevel(TFilePath(path))) return true; if (TSystem::doesExistFileOrLevel(TFilePath(path))) return true;
// check the Tahoma root directory next // Let's try and autodetect the exe included with release
path = QDir::currentPath() + "/ffprobe"; QStringList folderList;
#if defined(_WIN32)
path = path + ".exe"; folderList.append(".");
#endif folderList.append("./ffmpeg"); // ffmpeg folder
if (TSystem::doesExistFileOrLevel(TFilePath(path))) {
Preferences::instance()->setValue(ffmpegPath, QDir::currentPath());
return true;
}
#ifdef MACOSX #ifdef MACOSX
path = QDir::currentPath() + "/" + // Look inside app
QString::fromStdString(TEnv::getApplicationFileName()) + folderList.append("./" +
".app/ffmpeg/ffprobe"; QString::fromStdString(TEnv::getApplicationFileName()) +
if (TSystem::doesExistFileOrLevel(TFilePath(path))) { ".app/ffmpeg"); // ffmpeg folder
Preferences::instance()->setValue( #elif defined LINUX
ffmpegPath, QDir::currentPath() + "/" + // Need to account for symbolic links
QString::fromStdString(TEnv::getApplicationFileName()) + folderList.append(TEnv::getWorkingDirectory().getQString() +
".app/ffmpeg/"); "/ffmpeg"); // ffmpeg folder
return true;
}
#endif #endif
#ifdef LINUX QString exePath = TSystem::findFileLocation(folderList, exe);
QString currentPath = TEnv::getWorkingDirectory().getQString();
path = currentPath + "/ffmpeg/ffprobe"; if (!exePath.isEmpty()) {
if (TSystem::doesExistFileOrLevel(TFilePath(path))) { Preferences::instance()->setValue(ffmpegPath, exePath);
Preferences::instance()->setValue(ffmpegPath, currentPath + "/ffmpeg/");
return true; return true;
} }
#endif
// give up // give up
return false; return false;