mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 08:48:13 +00:00
* Remove a lot of old code from render_queue regarding clients * More code cleanup * More code cleanup * Move everything around * Minor log change
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
try:
|
|
from .base_engine import *
|
|
except ImportError:
|
|
from base_engine import *
|
|
import re
|
|
|
|
|
|
class FFMPEG(BaseRenderEngine):
|
|
|
|
@classmethod
|
|
def version(cls):
|
|
version = None
|
|
try:
|
|
ver_out = subprocess.check_output([cls.renderer_path(), '-version'],
|
|
timeout=SUBPROCESS_TIMEOUT).decode('utf-8')
|
|
match = re.match(".*version\s*(\S+)\s*Copyright", ver_out)
|
|
if match:
|
|
version = match.groups()[0]
|
|
except Exception as e:
|
|
logger.error("Failed to get FFMPEG version: {}".format(e))
|
|
return version
|
|
|
|
@classmethod
|
|
def get_encoders(cls):
|
|
encoders_raw = subprocess.check_output([cls.renderer_path(), '-encoders'], stderr=subprocess.DEVNULL,
|
|
timeout=SUBPROCESS_TIMEOUT).decode('utf-8')
|
|
pattern = '(?P<type>[VASFXBD.]{6})\s+(?P<name>\S{2,})\s+(?P<description>.*)'
|
|
encoders = [m.groupdict() for m in re.finditer(pattern, encoders_raw)]
|
|
return encoders
|
|
|
|
@classmethod
|
|
def get_all_formats(cls):
|
|
formats_raw = subprocess.check_output([cls.renderer_path(), '-formats'], stderr=subprocess.DEVNULL,
|
|
timeout=SUBPROCESS_TIMEOUT).decode('utf-8')
|
|
pattern = '(?P<type>[DE]{1,2})\s+(?P<name>\S{2,})\s+(?P<description>.*)'
|
|
formats = [m.groupdict() for m in re.finditer(pattern, formats_raw)]
|
|
return formats
|
|
|
|
@classmethod
|
|
def get_output_formats(cls):
|
|
return [x for x in cls.get_all_formats() if 'E' in x['type'].upper()] |