Skip to content

Commit

Permalink
Merge pull request #30 from genkobar/find-ffmpeg-path-in-environment
Browse files Browse the repository at this point in the history
Attempt to find ffmpeg path in the environment
  • Loading branch information
sverrirs authored Jan 18, 2024
2 parents 6a0e1fc + 09ff1e0 commit aa803f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ruvsarpur.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -897,6 +899,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.')

Expand Down
18 changes: 18 additions & 0 deletions src/utilities.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit aa803f8

Please sign in to comment.