[FFmpeg-user] NVDEC/NVENC resources underutilization

James Girotti james.girotti at gmail.com
Wed Feb 28 20:54:22 EET 2018


>
> I see 30% NVENC performance loss when the transcoding path is NVDEC - RAM
> - NVENC. Does it mean system memory bandwidth is a bottleneck in this case?
> Am I faced other unavoidable overheads?
>

You will definitely see a performance loss when not using '-hwaccel cuvid',
but I have recently experienced a similar decrease in NVEnc encoding
speeds. The change happened a couple months ago after I was updating my
system. I haven't fully investigated, but I believe it was either a change
in ffmpeg or the linux kernel. What I believe is happening is that ffmpeg
is single-threading (as it must to reliable transcode), but the thread
migrates between CPU cores. On my system this leads to much lower CPU clock
speeds, because the up_threshold is never met long enough on a single core.
And thus transcoding speed is significantly impacted.

What I have done to remediate this is to use "taskset" to ensure ffmpeg
runs on a single CPU core. I don't have any specific numbers to back this
up, but I have been satisfied enough with the results to continue using it.
I tried setting two or more CPU cores, but generally only set one CPU core.
An example might look like this:

taskset -c 0 ffmpeg -hwaccel cuvid -c:v mpeg4_cuvid -i foo.avi -map 0:v:0
-c:v h264_nvenc bar.mkv

Or two cores:

taskset -c 0,1 ffmpeg -hwaccel cuvid -c:v mpeg4_cuvid -i foo.avi -map 0:v:0
-c:v h264_nvenc bar.mkv

You can test to see what gives you the best results. Another note, it is
not sufficient to use '-threads 1' instead of 'taskset' to alleviate this
slow-down as that single thread still migrates between cores.


More information about the ffmpeg-user mailing list