Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to find ffmpeg path in the environment #30

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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.')

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")