Better error handling for ffmpeg.get_all_formats()

This commit is contained in:
2023-10-21 17:57:15 -07:00
parent c1eeabad78
commit 671e2e3f32

View File

@@ -33,11 +33,15 @@ class FFMPEG(BaseRenderEngine):
return encoders return encoders
def get_all_formats(self): def get_all_formats(self):
try:
formats_raw = subprocess.check_output([self.renderer_path(), '-formats'], stderr=subprocess.DEVNULL, formats_raw = subprocess.check_output([self.renderer_path(), '-formats'], stderr=subprocess.DEVNULL,
timeout=SUBPROCESS_TIMEOUT).decode('utf-8') timeout=SUBPROCESS_TIMEOUT).decode('utf-8')
pattern = '(?P<type>[DE]{1,2})\s+(?P<id>\S{2,})\s+(?P<name>.*)' pattern = '(?P<type>[DE]{1,2})\s+(?P<id>\S{2,})\s+(?P<name>.*)\r'
all_formats = [m.groupdict() for m in re.finditer(pattern, formats_raw)] all_formats = [m.groupdict() for m in re.finditer(pattern, formats_raw)]
return all_formats return all_formats
except Exception as e:
logger.error(f"Error getting all formats: {e}")
return []
def extension_for_format(self, ffmpeg_format): def extension_for_format(self, ffmpeg_format):
# Extract the common extension using regex # Extract the common extension using regex