Skip to content

[video_transcoder] 0.1.18#23

Merged
Josh5 merged 1 commit intoUnmanic:masterfrom
yajrendrag:pr-video_transcoder
Mar 17, 2026
Merged

[video_transcoder] 0.1.18#23
Josh5 merged 1 commit intoUnmanic:masterfrom
yajrendrag:pr-video_transcoder

Conversation

@yajrendrag
Copy link
Contributor

This PR makes the same modifications to qsv and vaapi encoders as was made for nvenc in v0.1.7:

The PR handles a situation where qsv/vaapi hardware decoding is used and the source content is encoded in such a way that the colorspace changes mid-stream. Evidently this is fairly common as H.264 allows this and it seems it can happen in certain scenarios - e.g., HDHR OTA broadcast captures at commercial boundaries and others.

The fix uses a combination of a reinit_filter 0 option that is added as a keyword argument to instruct ffmpeg to ignore the colorspace change (so it keeps the existing filtergraph and not try to rebuild it) and then in the generate filtergraph function we add an explicit branch to handle the case of HW decode + no SW filters. in the case of a colorspace change it would cause ffmpeg to detect a hwaccel change which it couldn't handle. so we output frames instead to the CPU, the reinit_filter 0 option ignores the colorspace change, and then the frames get uploaded back to the GPU for encoding.

without this the plugin fails with a message similar to:

[fc#0 @ 0x55853af42c40] Reconfiguring filter graph because hwaccel changed
Impossible to convert between the formats supported by the filter 'scaler_out_#0:0' and the filter 'auto_scale_0'
[fc#0 @ 0x55853af42c40] Error reinitializing filters!
[fc#0 @ 0x55853af42c40] Task finished with error code: -38 (Function not implemented)
[fc#0 @ 0x55853af42c40] Terminating thread with return code -38 (Function not implemented)
[out#0/matroska @ 0x55853af59300] video:1073KiB audio:25271KiB subtitle:35KiB other streams:0KiB global headers:0KiB muxing overhead: 0.310660%
frame=  155 fps= 44 q=-0.0 Lsize=   26461KiB time=00:00:06.29 bitrate=34419.2kbits/s speed=1.78x    
Conversion failed!

this fix is gated within the plugin by the use of a new option: qsv_safe_decode/vaapi_safe_decode. if enabled, this will pass all frames through the CPU (decode and encode still done entirely in hardware) so the ffmpeg can avoid a failure. if qsv_safe_decode/vaapi_safe_decode is disabled, then all frames stay on the GPU, but if a midstream metadata change ocurrs that would cause ffmpeg to reinitialize the filtergraph it will cause a failure. the use of qsv_safe_decode/vaapi_safe_decode can be coupled with the reprocess_file plugin to automate this so the user can first try to process with all frames remaining on the GPU (qsv_safe_decode/vaapi_safe_decode disabled) but if it errors, the reprocess_plugin can be used to add the file back to the task queue to a duplicate library where everything is the same except qsv_safe_decode/vaapi_safe_decode is enabled.

@Josh5 Josh5 merged commit 7fd9508 into Unmanic:master Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants