Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

**<span style="color:#56adda">0.1.17</span>**
- adds nvenc_safe_decode option to allow plugin to avoid an error caused by colorspace changes in the file
- adds new path in the define_filtergraph function to move the frames off the GPU to avoid h/w accel failure due to midstream colorspace changes
- adds '-reinit_filter 0' option to the ffmpeg command line so that ffmpeg can ignore the filter change that would have resulted from the colorspace change
- the combination of these allows ffmpeg to successfully process the file rather than failing

**<span style="color:#56adda">0.1.16</span>**
- Add support for using the File Metadata helper for storing details on moved files (Requires Unmanic v0.3.0)
- Fix issue with settings not chaing encoder when the codec changes
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"on_worker_process": 1
},
"tags": "video,ffmpeg",
"version": "0.1.16"
"version": "0.1.17"
}
28 changes: 28 additions & 0 deletions lib/encoders/nvenc.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ def options(self):
return {
"nvenc_device": "none",
"nvenc_decoding_method": "cpu",
"nvenc_safe_decode": False,
"nvenc_preset": "p4",
"nvenc_tune": "auto",
"nvenc_profile": "main",
Expand Down Expand Up @@ -361,6 +362,11 @@ def generate_default_args(self):
if self.settings.get_setting('nvenc_decoding_method') in ['cuda', 'nvdec']:
generic_kwargs["-hwaccel_output_format"] = "cuda"

# Prevent filter graph reconfiguration on mid-stream parameter changes
# (e.g., color space metadata changing partway through a file)
if self.settings.get_setting('nvenc_safe_decode'):
generic_kwargs["-reinit_filter"] = "0"

return generic_kwargs, advanced_kwargs

def generate_filtergraphs(self, current_filter_args, smart_filters, encoder_name):
Expand Down Expand Up @@ -419,6 +425,16 @@ def generate_filtergraphs(self, current_filter_args, smart_filters, encoder_name
chain.append(target_color_config['setparams_filter'])
chain.append("hwupload_cuda")
start_filter_args.append(",".join(chain))
# HW decode, no SW filters:
elif self.settings.get_setting('nvenc_safe_decode'):
# output software frames to avoid
# hwaccel reconfiguration on mid-stream color space changes
generic_kwargs['-hwaccel_output_format'] = target_fmt
chain = [f"format={target_fmt}"]
if enc_supports_hdr and target_color_config.get('apply_color_params'):
chain.append(target_color_config['setparams_filter'])
chain.append("hwupload_cuda")
start_filter_args.append(",".join(chain))

# Add the smart filters to the end
end_filter_args += hw_smart_filters
Expand Down Expand Up @@ -643,6 +659,18 @@ def get_nvenc_decoding_method_form_settings(self):
values["display"] = "hidden"
return values

def get_nvenc_safe_decode_form_settings(self):
values = {
"label": "Safe decode mode",
"description": "Forces CPU-side frame handling to prevent failures on files with "
"inconsistent color space metadata (common in WEBDL sources).\n"
"Slightly slower due to GPU->CPU->GPU round-trip per frame.",
"sub_setting": True,
}
if self.settings.get_setting('mode') not in ['standard'] or self.settings.get_setting('nvenc_decoding_method') == "cpu":
values["display"] = "hidden"
return values

def get_nvenc_preset_form_settings(self):
values = {
"label": "Encoder quality preset",
Expand Down