Skip to content

Commit

Permalink
Prefer system ffmpeg binary over embedded
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Nov 30, 2024
1 parent d57cca5 commit 69b95ac
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/onthespot/otsconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,22 @@ def __init__(self, cfg_path=None):
os.makedirs(self.get("download_root"), exist_ok=True)
# Set ffmpeg path
self.app_root = os.path.dirname(os.path.realpath(__file__))
if os.path.isfile(os.path.join(self.app_root, 'bin', 'ffmpeg', 'ffmpeg' + self.ext_)):
# Try embedded binary at first
if which('ffmpeg'):
# Try system binaries first
print('Attempting to use system ffmpeg binary !')
self.set_('_ffmpeg_bin_path', os.path.abspath(which('ffmpeg')))
elif os.path.isfile(os.path.join(self.app_root, 'bin', 'ffmpeg', 'ffmpeg' + self.ext_)):
# Try embedded binary next
print('FFMPEG found in package !')
self.set_('_ffmpeg_bin_path',
os.path.abspath(os.path.join(self.app_root, 'bin', 'ffmpeg', 'ffmpeg' + self.ext_)))
elif os.path.isfile(os.path.join(self.get('ffmpeg_bin_dir', '.'), 'ffmpeg' + self.ext_)):
# Now try user defined binary path
# Try user defined binary path neither are found
print('FFMPEG found at config:ffmpeg_bin_dir !')
self.set_('_ffmpeg_bin_path',
os.path.abspath(os.path.join(self.get('ffmpeg_bin_dir', '.'), 'ffmpeg' + self.ext_)))
else:
# Try system binaries as fallback
print('Attempting to use system ffmpeg binary !')
self.set_('_ffmpeg_bin_path', os.path.abspath(which('ffmpeg')) if which('ffmpeg') else 'ffmpeg' + self.ext_)
print('Failed to find ffmpeg binary, please consider installing ffmpeg or defining its path.')
print("Using ffmpeg binary at: ", self.get('_ffmpeg_bin_path'))
self.set_('_log_file', os.path.join(cache_dir(), "onthespot", "logs", self.session_uuid, "onthespot.log"))
self.set_('_cache_dir', os.path.join(cache_dir(), "onthespot"))
Expand Down

0 comments on commit 69b95ac

Please sign in to comment.