diff --git a/changelog.md b/changelog.md
index 8b53487..bc78eb2 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,3 +1,10 @@
+
+**0.1.17**
+- 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
+
**0.1.16**
- 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
diff --git a/info.json b/info.json
index 7aa7ce9..4078728 100644
--- a/info.json
+++ b/info.json
@@ -12,5 +12,5 @@
"on_worker_process": 1
},
"tags": "video,ffmpeg",
- "version": "0.1.16"
+ "version": "0.1.17"
}
diff --git a/lib/encoders/nvenc.py b/lib/encoders/nvenc.py
index 527bb2c..041eeb1 100644
--- a/lib/encoders/nvenc.py
+++ b/lib/encoders/nvenc.py
@@ -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",
@@ -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):
@@ -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
@@ -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",