Skip to content

Commit

Permalink
Prefix VAAPI config options in plugin settings file
Browse files Browse the repository at this point in the history
This change is to isolate them from libx encoder settings. Users will need to reconfigure some VAAPI settings
  • Loading branch information
Josh5 committed Dec 29, 2023
1 parent 74a3221 commit 7ab62fd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 39 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**<span style="color:#56adda">0.1.0</span>**
- 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)

**<span style="color:#56adda">0.0.10</span>**
- Add support for QSV HW accelerated decoding
Expand Down
52 changes: 26 additions & 26 deletions lib/encoders/vaapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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,
Expand All @@ -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
13 changes: 0 additions & 13 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7ab62fd

Please sign in to comment.