From 7ed59496eb050a3512adcc2298d04f6534d23251 Mon Sep 17 00:00:00 2001 From: nyanpasu64 Date: Tue, 29 Jan 2019 22:09:00 -0800 Subject: [PATCH] Show error message if ffplay missing (not just ffmpeg) (#168) --- corrscope/gui/__init__.py | 2 +- corrscope/outputs.py | 7 +++++-- corrscope/settings/paths.py | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/corrscope/gui/__init__.py b/corrscope/gui/__init__.py index 70888e8..e015c1f 100644 --- a/corrscope/gui/__init__.py +++ b/corrscope/gui/__init__.py @@ -984,7 +984,7 @@ class DownloadFFmpegActivity: path_uri = qc.QUrl.fromLocalFile(paths.PATH_dir).toString() required = ( - f"FFmpeg must be in PATH or " + f"FFmpeg+FFplay must be in PATH or " f'corrscope folder in order to use corrscope.
' ) diff --git a/corrscope/outputs.py b/corrscope/outputs.py index 69dd1bb..36373cb 100644 --- a/corrscope/outputs.py +++ b/corrscope/outputs.py @@ -107,7 +107,7 @@ class _FFmpegProcess: return subprocess.Popen( args, stdin=subprocess.PIPE, bufsize=bufsize, **kwargs ) - except FileNotFoundError as e: + except FileNotFoundError: raise MissingFFmpegError() def _generate_args(self) -> List[str]: @@ -261,7 +261,10 @@ class FFplayOutput(PipeOutput): p1 = ffmpeg.popen(["-"], self.bufsize, stdout=subprocess.PIPE) ffplay = shlex.split("ffplay -autoexit -") + FFMPEG_QUIET - p2 = subprocess.Popen(ffplay, stdin=p1.stdout) + try: + p2 = subprocess.Popen(ffplay, stdin=p1.stdout) + except FileNotFoundError: + raise MissingFFmpegError() p1.stdout.close() # assert p2.stdin is None # True unless Popen is being mocked (test_output). diff --git a/corrscope/settings/paths.py b/corrscope/settings/paths.py index a8eb45a..630d6be 100644 --- a/corrscope/settings/paths.py +++ b/corrscope/settings/paths.py @@ -53,7 +53,9 @@ class MissingFFmpegError(CorrError): ffmpeg_url = get_ffmpeg_url() can_download = bool(ffmpeg_url) - message = f'FFmpeg must be in PATH or "{PATH_dir}" in order to use corrscope.\n' + message = ( + f'FFmpeg+FFplay must be in PATH or "{PATH_dir}" in order to use corrscope.\n' + ) if can_download: message += f"Download ffmpeg from {ffmpeg_url}."