Skip to content

Commit fafc967

Browse files
authored
Merge pull request #22 from yajrendrag/pr-video_transcoder
[video_transcoder] 0.1.7
2 parents 9dd5593 + 69244fa commit fafc967

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2+
**<span style="color:#56adda">0.1.17</span>**
3+
- adds nvenc_safe_decode option to allow plugin to avoid an error caused by colorspace changes in the file
4+
- 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
5+
- 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
6+
- the combination of these allows ffmpeg to successfully process the file rather than failing
7+
18
**<span style="color:#56adda">0.1.16</span>**
29
- Add support for using the File Metadata helper for storing details on moved files (Requires Unmanic v0.3.0)
310
- Fix issue with settings not chaing encoder when the codec changes

info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
"on_worker_process": 1
1313
},
1414
"tags": "video,ffmpeg",
15-
"version": "0.1.16"
15+
"version": "0.1.17"
1616
}

lib/encoders/nvenc.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ def options(self):
327327
return {
328328
"nvenc_device": "none",
329329
"nvenc_decoding_method": "cpu",
330+
"nvenc_safe_decode": False,
330331
"nvenc_preset": "p4",
331332
"nvenc_tune": "auto",
332333
"nvenc_profile": "main",
@@ -361,6 +362,11 @@ def generate_default_args(self):
361362
if self.settings.get_setting('nvenc_decoding_method') in ['cuda', 'nvdec']:
362363
generic_kwargs["-hwaccel_output_format"] = "cuda"
363364

365+
# Prevent filter graph reconfiguration on mid-stream parameter changes
366+
# (e.g., color space metadata changing partway through a file)
367+
if self.settings.get_setting('nvenc_safe_decode'):
368+
generic_kwargs["-reinit_filter"] = "0"
369+
364370
return generic_kwargs, advanced_kwargs
365371

366372
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
419425
chain.append(target_color_config['setparams_filter'])
420426
chain.append("hwupload_cuda")
421427
start_filter_args.append(",".join(chain))
428+
# HW decode, no SW filters:
429+
elif self.settings.get_setting('nvenc_safe_decode'):
430+
# output software frames to avoid
431+
# hwaccel reconfiguration on mid-stream color space changes
432+
generic_kwargs['-hwaccel_output_format'] = target_fmt
433+
chain = [f"format={target_fmt}"]
434+
if enc_supports_hdr and target_color_config.get('apply_color_params'):
435+
chain.append(target_color_config['setparams_filter'])
436+
chain.append("hwupload_cuda")
437+
start_filter_args.append(",".join(chain))
422438

423439
# Add the smart filters to the end
424440
end_filter_args += hw_smart_filters
@@ -643,6 +659,18 @@ def get_nvenc_decoding_method_form_settings(self):
643659
values["display"] = "hidden"
644660
return values
645661

662+
def get_nvenc_safe_decode_form_settings(self):
663+
values = {
664+
"label": "Safe decode mode",
665+
"description": "Forces CPU-side frame handling to prevent failures on files with "
666+
"inconsistent color space metadata (common in WEBDL sources).\n"
667+
"Slightly slower due to GPU->CPU->GPU round-trip per frame.",
668+
"sub_setting": True,
669+
}
670+
if self.settings.get_setting('mode') not in ['standard'] or self.settings.get_setting('nvenc_decoding_method') == "cpu":
671+
values["display"] = "hidden"
672+
return values
673+
646674
def get_nvenc_preset_form_settings(self):
647675
values = {
648676
"label": "Encoder quality preset",

0 commit comments

Comments
 (0)