codec: cap FFmpeg decoder frame threads at 4

threads=auto spawns one decode thread per logical core per decoder (16
observed on a 24-core box); with cores-2 render workers decoding
concurrently the machine is oversubscribed several times over and the
playback-audio render thread gets starved (late chunks are dropped).
4 threads decode 1080p h264 far past real-time; preview throughput comes
from the worker pool, not per-decoder threading. Applies to both the
software open path and the hwaccel open path.
This commit is contained in:
2026-08-29 19:52:28 +08:00
parent 9dab9efc38
commit 81c3839937
2 changed files with 17 additions and 2 deletions
+1 -1
View File
@@ -195,7 +195,7 @@ pub fn open_hw_accel(
// context frees it with the context.
unsafe { (*context.as_mut_ptr()).hw_device_ctx = device };
let mut opts = Dictionary::new();
opts.set("threads", "auto");
opts.set("threads", &crate::ffmpeg::decoder_threads());
context
.decoder()
.open_as_with(codec, opts)