Camera Rendering Buffers and Stutters When Processing Large Video Files with FFmpeg

Hi NVIDIA support team,

When rendering a real-time camera, I use ffmpeg to process a large video file(like 4G or even larger) at the same time. I noticed that the video frames are buffering and stuttering.

Pipeline:
DISPLAY=:0 gst-launch-1.0 filesrc location=/home/user/jellyfish-120-mbps-4k-uhd-hevc-10bit.mkv ! matroskademux name=demux demux.video_0 ! queue ! h265parse ! nvv4l2decoder ! nvvidconv ! xvimagesink

FFmpeg command:
ffmpeg -i ${file_name} -c copy -f segment -segment_time 600 -segment_format_options movflags=+faststart -reset_timestamps 1 ./${file_name}_%02d.mp4 -y

And there are some warning indicated that “a lot of buffers are being dropped” duration stuttering.

The requirement can be summarized as “real-time video rendering has higher priority, and the low rate of large file processing is accepted”. Are there any possible solutions of this issue from your perspective? Thanks in advance.

Hi,
There is additional buffer copy in using xvimagesink. Please try nv3dsink:

DISPLAY=:0 gst-launch-1.0 filesrc location=/home/user/jellyfish-120-mbps-4k-uhd-hevc-10bit.mkv ! matroskademux name=demux demux.video_0 ! queue ! h265parse ! nvv4l2decoder ! nvvidconv ! nv3dsink

Hi DaneLLL,

Could you introduce a little bit more about the buffer copy? I get confused about the deep reason why some camera frames lag when large file is processed by ffmpeg, does it caused by “lack of available free memory” or “all buffers(in user space or kernel) at that moment are occupied by ffmpeg”?

Hi,
The decoded frame data is in NvBufSurface (hardware DMA buffer) and it requires CPU buffers in ffmpeg, so decoded data is copied from NvBufSurface to CPU buffer. This may bring significant latency in large resolution. For optimal solution, we would expect frame data is in NvBufSurface in the whole pipeline, to run in zero buffer copy.

Hi DaneLLL,

Switching to nv3dsink is not possible due to the known bug on 32.6.1 (Video playback is jittery when using multiple nv3dsink instances in the same program/process

And using nvcompositor is not an option as well. Our APP ( N - N video conference) need to support user joining/leaving at any time while recording and transcoding in background. So both xvimagesink and ffmpeg are required in our case.

Could you please help check further?