I have a 4K video with hevc codec. I played it with caspar and obs studio. I ascertain that caspar don't use cpu best for decode, while obs studio is good. So caspar received late frame when obs studio play it smooth. I debuged and here is result:


@Julusian or @ronag, what do you say about this?
@ronag, v2.3.0 LTS or patch it later?
jsut remove i in 2.3
I not sure it can fix problem. I will try it
Oh. Problem at here:
https://github.com/CasparCG/server/blob/master/src/modules/ffmpeg/producer/av_producer.cpp#L125
Just remove it only
Oh. Problem at here:
/src/modules/ffmpeg/producer/av_producer.cpp@master#L125
Just remove it only
Removing that will increase the latency of some streams which is not appropriate. Should probably detect if it's not a live source and then let it auto pick threads.
https://github.com/CasparCG/server/blob/master/src/modules/ffmpeg/producer/av_producer.cpp#L108
This thread limit of 4 is this only in place for decoding or for the whole image preparation like de-interlacing, framerate conversion, chroma upsampling etc?
~Not sure if my issue is related but using casparcg server 2.3 commit 4176a9b on a unsupported ubuntu 20.04 (8core 2 * intel e5450 cpu and nvidia gtx640) shows no problems mixing 720p50 from the NDI producer to a PAL decklink consumer but a simple playback of a PAL dv codec videoclip on the same channel brings the system to stuttering/halt eventhough its load is around +-3.0 (cpu 40%) including the 720p50 ndi producer.~ Unrelated fixed by reducing channels from 3>2
If I try commenting out that threads line or upping it to 32 I am still unable to play back the 4k files I have tried, with overall cpu usage of 14%.
But commenting out the line as @ducthiem90 suggests does allow it to play smoothly. So it looks like we need to decide on a rule to disable the slice threading
I'm fine with letting ffmpeg auto decide thread type. Remove that line.
Different codecs have different capability flags and may not support setting threads to auto.
I have added code to check the capability flags and where threading is supported but auto isn't I have set the default number of threads to the detected number of CPU cores. It is possible to set the decode threads from the configuration file with the key _ffmpeg/producer/threads_.
For clarity deinterlacing and so on mentioned above is done using FFmpeg filters. The filter is currently set to use 16 threads.
For clarity deinterlacing and so on mentioned above is done using FFmpeg filters. The filter is currently set to use 16 threads.
Thanks for explanation.
Most helpful comment
Removing that will increase the latency of some streams which is not appropriate. Should probably detect if it's not a live source and then let it auto pick threads.