Skip to content

Commit aa803f8

Browse files
authored
Merge pull request #30 from genkobar/find-ffmpeg-path-in-environment
Attempt to find ffmpeg path in the environment
2 parents 6a0e1fc + 09ff1e0 commit aa803f8

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/ruvsarpur.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
from requests.packages.urllib3.exceptions import InsecureRequestWarning
5959
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
6060

61+
import utilities
62+
6163
# Lambdas as shorthands for printing various types of data
6264
# See https://pypi.python.org/pypi/termcolor for more info
6365
color_title = lambda x: colored(x, 'cyan', 'on_grey')
@@ -897,6 +899,12 @@ def findffmpeg(path_to_ffmpeg_install=None, working_dir=None):
897899
if os.path.isfile(bin_dist):
898900
return str(Path(bin_dist).resolve())
899901

902+
# Attempt to find ffmpeg in the environment
903+
try:
904+
return utilities.get_ffmpeg_location()
905+
except Exception:
906+
pass # Ignoring the exception
907+
900908
# Throw an error
901909
raise ValueError('Could not locate FFMPEG install, please use the --ffmpeg switch to specify the path to the ffmpeg executable on your system.')
902910

src/utilities.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import shutil
2+
3+
4+
def get_ffmpeg_location():
5+
"""
6+
Locate the ffmpeg executable in the system's PATH.
7+
8+
Returns:
9+
str: The path to the ffmpeg executable.
10+
11+
Raises:
12+
FileNotFoundError: If ffmpeg is not found in the PATH.
13+
"""
14+
ffmpeg_path = shutil.which("ffmpeg")
15+
if ffmpeg_path:
16+
return ffmpeg_path
17+
else:
18+
raise FileNotFoundError("ffmpeg not found in PATH")

0 commit comments

Comments
 (0)