From a3e784b0d1d1c7538ef5e34e7e782f2dcef7d55e Mon Sep 17 00:00:00 2001 From: Ross Patterson Date: Fri, 9 Aug 2019 18:30:22 -0700 Subject: [PATCH] Detect: Fix VAAPI handling, add -hwaccel_output_format handling --- ffmpeg/_detect.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ffmpeg/_detect.py b/ffmpeg/_detect.py index 8d796cd..76d447a 100644 --- a/ffmpeg/_detect.py +++ b/ffmpeg/_detect.py @@ -40,8 +40,17 @@ parser.add_argument( # List `hwaccel` options by order of expected performance when available. HWACCELS_BY_PERFORMANCE = [ - 'cuvid', 'amf', 'vdpau', - 'qsv', 'd3d11va', 'dxva2', 'vaapi', 'drm'] + # NVidia + 'nvdec', 'cuvid', 'cuda', + # AMD + 'amf', + # Windows + 'qsv', 'd3d11va', 'dxva2', + # Linux + 'vaapi', 'vdpau', 'drm'] +HWACCEL_OUTPUT_FORMATS = { + 'nvdec': 'cuda', + 'vaapi': 'vaapi'} # Loaded from JSON DATA = None @@ -126,6 +135,9 @@ def detect_codecs(decoder, encoder, hwaccels=None, cmd='ffmpeg'): hwaccel_kwargs = dict( input=dict(hwaccel=hwaccel['name']), output=dict(codec=hwaccel_encoder)) + if hwaccel['name'] in HWACCEL_OUTPUT_FORMATS: + hwaccel_kwargs['input']['hwaccel_output_format'] = ( + HWACCEL_OUTPUT_FORMATS[hwaccel['name']]) codecs_kwargs.append(hwaccel_kwargs) for hwaccel_decoder in hwaccel['codecs'].get( decoder, {}).get('decoders', []):