diff options
| author | tassaron | 2022-04-30 00:16:38 -0400 |
|---|---|---|
| committer | tassaron | 2022-04-30 00:16:38 -0400 |
| commit | 893c10c6ca8b7a9c04b9aaa086a46503166c880b (patch) | |
| tree | 48e13bce5049147a980bc191bd08ebc7490caaf9 /src | |
| parent | 340062712cd88bd1467b40fd49892566bfbccc04 (diff) | |
test if ffmpeg is really found at startup
Diffstat (limited to 'src')
| -rw-r--r-- | src/gui/mainwindow.py | 40 | ||||
| -rw-r--r-- | src/toolkit/ffmpeg.py | 31 |
2 files changed, 39 insertions, 32 deletions
diff --git a/src/gui/mainwindow.py b/src/gui/mainwindow.py index 1b28b7e..fcf4b4c 100644 --- a/src/gui/mainwindow.py +++ b/src/gui/mainwindow.py @@ -336,24 +336,32 @@ class MainWindow(QtWidgets.QMainWindow): log.info("Pillow version %s", Image.__version__) # verify Ffmpeg version - if not self.settings.value("ffmpegMsgShown"): - try: - with open(os.devnull, "w") as f: - ffmpegVers = checkOutput( - ['ffmpeg', '-version'], stderr=f - ) - goodVersion = str(ffmpegVers).split()[2].startswith('4') - except Exception: - goodVersion = False - else: - goodVersion = True - - if not goodVersion: + if not self.core.FFMPEG_BIN: self.showMessage( - msg="You're using an old version of Ffmpeg. " - "Some features may not work as expected." + msg="FFmpeg could not be found. This is a critical error. " + "Install FFmpeg, or download it and place the program executable " + "in the same folder as this program.", + icon='Critical' ) - self.settings.setValue("ffmpegMsgShown", True) + else: + if not self.settings.value("ffmpegMsgShown"): + try: + with open(os.devnull, "w") as f: + ffmpegVers = checkOutput( + [self.core.FFMPEG_BIN, '-version'], stderr=f + ) + goodVersion = str(ffmpegVers).split()[2].startswith('4') + except Exception: + goodVersion = False + else: + goodVersion = True + + if not goodVersion: + self.showMessage( + msg="You're using an old version of Ffmpeg. " + "Some features may not work as expected." + ) + self.settings.setValue("ffmpegMsgShown", True) # Hotkeys for projects QtWidgets.QShortcut("Ctrl+S", self, self.saveCurrentProject) diff --git a/src/toolkit/ffmpeg.py b/src/toolkit/ffmpeg.py index 256646e..5f9dec1 100644 --- a/src/toolkit/ffmpeg.py +++ b/src/toolkit/ffmpeg.py @@ -152,25 +152,24 @@ def closePipe(pipe): def findFfmpeg(): + if sys.platform == "win32": + bin = 'ffmpeg.exe' + else: + bin = 'ffmfpeg' + if getattr(sys, 'frozen', False): # The application is frozen - if sys.platform == "win32": - return os.path.join(core.Core.wd, 'ffmpeg.exe') - else: - return os.path.join(core.Core.wd, 'ffmpeg') + bin = os.path.join(core.Core.wd, bin) - else: - if sys.platform == "win32": - return "ffmpeg" - else: - try: - with open(os.devnull, "w") as f: - checkOutput( - ['ffmpeg', '-version'], stderr=f - ) - return "ffmpeg" - except (subprocess.CalledProcessError, FileNotFoundError): - return "avconv" + with open(os.devnull, "w") as f: + try: + checkOutput( + [bin, '-version'], stderr=f + ) + except (subprocess.CalledProcessError, FileNotFoundError): + bin = "" + + return bin def createFfmpegCommand(inputFile, outputFile, components, duration=-1): |
