From 0bf9fc89a8a5730da9c481689abaa76dd1202f4e Mon Sep 17 00:00:00 2001 From: Valdi Asgeirs Date: Thu, 28 Dec 2023 20:54:30 +0900 Subject: [PATCH 1/2] Add get_ffmpeg_location utility --- src/utilities.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/utilities.py diff --git a/src/utilities.py b/src/utilities.py new file mode 100644 index 0000000..018c7b6 --- /dev/null +++ b/src/utilities.py @@ -0,0 +1,18 @@ +import shutil + + +def get_ffmpeg_location(): + """ + Locate the ffmpeg executable in the system's PATH. + + Returns: + str: The path to the ffmpeg executable. + + Raises: + FileNotFoundError: If ffmpeg is not found in the PATH. + """ + ffmpeg_path = shutil.which("ffmpeg") + if ffmpeg_path: + return ffmpeg_path + else: + raise FileNotFoundError("ffmpeg not found in PATH") From 09ff1e03f7b8aa33d37039f6909328f5a6689d39 Mon Sep 17 00:00:00 2001 From: Valdi Asgeirs Date: Thu, 28 Dec 2023 20:58:29 +0900 Subject: [PATCH 2/2] Search env for ffmpeg --- src/ruvsarpur.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ruvsarpur.py b/src/ruvsarpur.py index 3ac3b5e..d469891 100644 --- a/src/ruvsarpur.py +++ b/src/ruvsarpur.py @@ -58,6 +58,8 @@ from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) +import utilities + # Lambdas as shorthands for printing various types of data # See https://pypi.python.org/pypi/termcolor for more info color_title = lambda x: colored(x, 'cyan', 'on_grey') @@ -891,6 +893,12 @@ def findffmpeg(path_to_ffmpeg_install=None, working_dir=None): if os.path.isfile(bin_dist): return str(Path(bin_dist).resolve()) + # Attempt to find ffmpeg in the environment + try: + return utilities.get_ffmpeg_location() + except Exception: + pass # Ignoring the exception + # Throw an error raise ValueError('Could not locate FFMPEG install, please use the --ffmpeg switch to specify the path to the ffmpeg executable on your system.')