Skip to content

Commit

Permalink
Upgraded FFMPEG check
Browse files Browse the repository at this point in the history
Signed-off-by: octimot <[email protected]>
  • Loading branch information
octimot committed Nov 10, 2022
1 parent e9ff360 commit 0898b29
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
38 changes: 36 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6357,10 +6357,34 @@ def check_ffmpeg(self):

try:

# first, check if the user added the ffmpeg path to the app settings
ffmpeg_path_custom = self.get_app_setting(setting_name='ffmpeg_path')

# if the ffmpeg path is not empty
if ffmpeg_path_custom is not None:

logger.debug('Found custom ffmpeg path in the app settings: {}'.format(ffmpeg_path_custom))

# add it to the environment variables
os.environ['FFMPEG_BINARY'] = ffmpeg_path_custom

# and check if it's working

logger.debug('Looking for ffmpeg in env variable.')

# get the FFMPEG_BINARY variable or try the ffmpeg command if not
ffmpeg_binary = os.getenv('FFMPEG_BINARY', 'ffmpeg')
# get the FFMPEG_BINARY variable
ffmpeg_binary = os.getenv('FFMPEG_BINARY')

# if the variable is empty, try to find ffmpeg in the PATH
if ffmpeg_binary is None or ffmpeg_binary == '':
logger.warning('FFMPEG_BINARY env variable is empty. Looking for ffmpeg in PATH.')
import shutil
ffmpeg_binary = ffmpeg_binary if ffmpeg_binary else shutil.which('ffmpeg')

# if ffmpeg is still not found in the path either, try to brute force it
if ffmpeg_binary is None:
logger.warning('FFMPEG_BINARY environment variable not set. Trying to use "ffmpeg".')
ffmpeg_binary = 'ffmpeg'

cmd = [
ffmpeg_binary]
Expand All @@ -6372,10 +6396,20 @@ def check_ffmpeg(self):

logger.debug('FFMPEG exit code: {}'.format(exit_code))

if exit_code == 1:
logger.debug('FFMPEG found at {}'.format(ffmpeg_binary))

# if it does, just return true
return True

except FileNotFoundError:

# print the exact exception
import traceback
traceback_str = traceback.format_exc()

logger.error(traceback_str)

# if the ffmpeg binary wasn't found, we presume that ffmpeg is not installed on the machine
return False

Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.17.0"
__version__ = "0.17.1"

0 comments on commit 0898b29

Please sign in to comment.