From 7ab62fddbcc87483d00039c30f5c80656bc16603 Mon Sep 17 00:00:00 2001 From: "Josh.5" Date: Sat, 30 Dec 2023 00:44:37 +1300 Subject: [PATCH] Prefix VAAPI config options in plugin settings file This change is to isolate them from libx encoder settings. Users will need to reconfigure some VAAPI settings --- changelog.md | 1 + lib/encoders/vaapi.py | 52 +++++++++++++++++++++---------------------- plugin.py | 13 ----------- 3 files changed, 27 insertions(+), 39 deletions(-) diff --git a/changelog.md b/changelog.md index 26189bb..42e038e 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ **0.1.0** - Stable release - Prefix QSV config options in plugin settings file to isolate them from libx encoder settings (users will need to reconfigure some QSV settings) +- Prefix VAAPI config options in plugin settings file to isolate them from libx encoder settings (users will need to reconfigure some VAAPI settings) **0.0.10** - Add support for QSV HW accelerated decoding diff --git a/lib/encoders/vaapi.py b/lib/encoders/vaapi.py index 3b724a5..62da8b1 100644 --- a/lib/encoders/vaapi.py +++ b/lib/encoders/vaapi.py @@ -58,12 +58,12 @@ def __init__(self, settings): @staticmethod def options(): return { - "encoder_ratecontrol_method": "ICQ", - "constant_quantizer_scale": "25", - "constant_quality_scale": "23", - "average_bitrate": "5", - "vaapi_device": "none", - "enabled_hw_decoding": True, + "vaapi_device": "none", + "vaapi_enabled_hw_decoding": True, + "vaapi_encoder_ratecontrol_method": "ICQ", + "vaapi_constant_quantizer_scale": "25", + "vaapi_constant_quality_scale": "23", + "vaapi_average_bitrate": "5", } @staticmethod @@ -93,7 +93,7 @@ def generate_default_args(settings): hardware_device = hardware_devices[0] # Check if we are using a VAAPI decoder also... - if settings.get_setting('enabled_hw_decoding'): + if settings.get_setting('vaapi_enabled_hw_decoding'): # Set a named global device that can be used with various params dev_id = 'vaapi0' # Configure args such that when the input may or may not be able to be decoded with hardware we can do: @@ -135,27 +135,27 @@ def args(self, stream_id): return stream_encoding stream_encoding += [ - '-rc_mode', str(self.settings.get_setting('encoder_ratecontrol_method')), + '-rc_mode', str(self.settings.get_setting('vaapi_encoder_ratecontrol_method')), ] - if self.settings.get_setting('encoder_ratecontrol_method') in ['CQP', 'ICQ']: - if self.settings.get_setting('encoder_ratecontrol_method') in ['CQP']: + if self.settings.get_setting('vaapi_encoder_ratecontrol_method') in ['CQP', 'ICQ']: + if self.settings.get_setting('vaapi_encoder_ratecontrol_method') in ['CQP']: stream_encoding += [ - '-q', str(self.settings.get_setting('constant_quantizer_scale')), + '-q', str(self.settings.get_setting('vaapi_constant_quantizer_scale')), ] - elif self.settings.get_setting('encoder_ratecontrol_method') in ['ICQ']: + elif self.settings.get_setting('vaapi_encoder_ratecontrol_method') in ['ICQ']: stream_encoding += [ - '-global_quality', str(self.settings.get_setting('constant_quality_scale')), + '-global_quality', str(self.settings.get_setting('vaapi_constant_quality_scale')), ] else: # Configure the encoder with a bitrate-based mode # Set the max and average bitrate (used by all bitrate-based modes) stream_encoding += [ - '-b:v:{}'.format(stream_id), '{}M'.format(self.settings.get_setting('average_bitrate')), + '-b:v:{}'.format(stream_id), '{}M'.format(self.settings.get_setting('vaapi_average_bitrate')), ] - if self.settings.get_setting('encoder_ratecontrol_method') == 'CBR': + if self.settings.get_setting('vaapi_encoder_ratecontrol_method') == 'CBR': # Add 'maxrate' with the same value to make CBR mode stream_encoding += [ - '-maxrate', '{}M'.format(self.settings.get_setting('average_bitrate')), + '-maxrate', '{}M'.format(self.settings.get_setting('vaapi_average_bitrate')), ] return stream_encoding @@ -206,17 +206,17 @@ def get_vaapi_device_form_settings(self): values["display"] = "hidden" return values - def get_enabled_hw_decoding_form_settings(self): + def get_vaapi_enabled_hw_decoding_form_settings(self): values = { "label": "Enable HW Decoding", "sub_setting": True, - "description": "Will fallback to software decoding and hardware encoding when the input is not be hardware decodable.", + "description": "Will fallback to software decoding and hardware encoding when the input codec is not supported.", } if self.settings.get_setting('mode') not in ['standard']: values["display"] = "hidden" return values - def get_encoder_ratecontrol_method_form_settings(self): + def get_vaapi_encoder_ratecontrol_method_form_settings(self): values = { "label": "Encoder ratecontrol method", "sub_setting": True, @@ -249,12 +249,12 @@ def get_encoder_ratecontrol_method_form_settings(self): # "value": "AVBR", # "label": "AVBR - Average variable bitrate mode", # }, - self.__set_default_option(values['select_options'], 'encoder_ratecontrol_method', default_option='CQP') + self.__set_default_option(values['select_options'], 'vaapi_encoder_ratecontrol_method', default_option='CQP') if self.settings.get_setting('mode') not in ['standard']: values["display"] = "hidden" return values - def get_constant_quantizer_scale_form_settings(self): + def get_vaapi_constant_quantizer_scale_form_settings(self): # Lower is better values = { "label": "Constant quantizer scale", @@ -267,11 +267,11 @@ def get_constant_quantizer_scale_form_settings(self): } if self.settings.get_setting('mode') not in ['standard']: values["display"] = "hidden" - if self.settings.get_setting('encoder_ratecontrol_method') != 'CQP': + if self.settings.get_setting('vaapi_encoder_ratecontrol_method') != 'CQP': values["display"] = "hidden" return values - def get_constant_quality_scale_form_settings(self): + def get_vaapi_constant_quality_scale_form_settings(self): # Lower is better values = { "label": "Constant quality scale", @@ -284,11 +284,11 @@ def get_constant_quality_scale_form_settings(self): } if self.settings.get_setting('mode') not in ['standard']: values["display"] = "hidden" - if self.settings.get_setting('encoder_ratecontrol_method') not in ['LA_ICQ', 'ICQ']: + if self.settings.get_setting('vaapi_encoder_ratecontrol_method') not in ['LA_ICQ', 'ICQ']: values["display"] = "hidden" return values - def get_average_bitrate_form_settings(self): + def get_vaapi_average_bitrate_form_settings(self): values = { "label": "Bitrate", "sub_setting": True, @@ -301,6 +301,6 @@ def get_average_bitrate_form_settings(self): } if self.settings.get_setting('mode') not in ['standard']: values["display"] = "hidden" - if self.settings.get_setting('encoder_ratecontrol_method') not in ['VBR', 'LA', 'CBR']: + if self.settings.get_setting('vaapi_encoder_ratecontrol_method') not in ['VBR', 'LA', 'CBR']: values["display"] = "hidden" return values diff --git a/plugin.py b/plugin.py index dda85f5..41e8497 100644 --- a/plugin.py +++ b/plugin.py @@ -104,25 +104,12 @@ def __encoder_settings_object(self): """ # Initial options forces the order they appear in the settings list # We need this because some encoders have settings that - initial_options_order = { - "nvenc_device": "", - "nvenc_decoding_method": "", - "qsv_decoding_method": "", - "preset": "", - "tune": "", - "profile": "", - "encoder_ratecontrol_method": "", - "constant_quantizer_scale": "", - "constant_quality_scale": "", - "average_bitrate": "", - } # Fetch all encoder settings from encoder libs libx_options = LibxEncoder.options() qsv_options = QsvEncoder.options() vaapi_options = VaapiEncoder.options() nvenc_options = NvencEncoder.options() return { - **initial_options_order, **libx_options, **qsv_options, **vaapi_options,