From a6601e3a2fd714284a1e10b3b330f9230d93a17d Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Mon, 28 Aug 2017 20:29:00 +0300 Subject: [PATCH] find_ffmpeg() now correctly returns codecs with their encoders/decoders --- motioneye/mediafiles.py | 27 +++++++++++++++++++++++++-- motioneye/motionctl.py | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/motioneye/mediafiles.py b/motioneye/mediafiles.py index 274fb5c..605ea09 100644 --- a/motioneye/mediafiles.py +++ b/motioneye/mediafiles.py @@ -225,8 +225,31 @@ def find_ffmpeg(): return None, None, None lines = output.split('\n') - matches = [re.match('^ [DEVILSA.]{6} ([\w+_]+) ', l) for l in lines] - codecs = set([m.group(1) for m in matches if m]) + lines = [l for l in lines if re.match('^ [DEVILSA.]{6} [^=].*', l)] + + codecs = {} + for line in lines: + m = re.match('^ [DEVILSA.]{6} ([\w+_]+)', line) + if not m: + continue + + codec = m.group(1) + + decoders = set() + encoders = set() + + m = re.search('decoders: ([\w\s_]+)+', line) + if m: + decoders = set(m.group(1).split()) + + m = re.search('encoders: ([\w\s_]+)+', line) + if m: + encoders = set(m.group(1).split()) + + codecs[codec] = { + 'encoders': encoders, + 'decoders': decoders + } logging.debug('using ffmpeg version %s' % version) diff --git a/motioneye/motionctl.py b/motioneye/motionctl.py index 351b887..042de1d 100644 --- a/motioneye/motionctl.py +++ b/motioneye/motionctl.py @@ -388,7 +388,7 @@ def has_h264_omx_support(): # TODO also check for motion codec parameter support - return 'h264_omx' in codecs + return 'h264_omx' in codecs.get('h264', {}).get('encoders', set()) def get_rtsp_support(): -- 2.39.5