I’m developing an application that captures raw video frames from a live source, and then uses the FFmpeg libraries (calls to av_*** etc) to filter and then encode the frames, with the encoding done using NVENC. I’m using latest FFmpeg code together with the latest NVENC SDK 10.
I am trying to reduce the latency down to the absolute minimum so I’m using the “ultra low latency” tuning info which I understand is supposed to pre-configure the more detailed settings to favour low latency.
As the trace snippet below shows, I find that I need to submit three uncompressed frames to NVENC before getting back the first encoded frame. Thereafter, the output is always two frames behind the input, which in a 50fps stream is a sizeable 40ms delay. Is this expected, or is there a way to reduce the latency down further? Ideally I’d submit one frame and be able to read back an encoded one right away, i.e. the compression algorithm would only be “looking back” rather than “looking forward” (and thus having to wait for more frames).
Perhaps it’s an issue with FFmpeg, but before I go down that road, I wanted to ask the developers here what should be possible with NVENC in this respect, what is the minimum latency achievable with the appropriate settings, when using HEVC?
24/07/20 15:21:30.6209305 : MWDEVICE_VIDEO_SERVER_CAPTURE: Captured video frame index 1000 with pts 33865544733947
24/07/20 15:21:30.6210664 : VIDEO_SERVER_TRANSCODER_STREAM_SESSION: Decoded video frame index 1000 with pts 33865544733947
24/07/20 15:21:30.6226942 : VIDEO_SERVER_TRANSCODER_STREAM_SESSION: Filtered video frame index 1000 with pts 169327723
24/07/20 15:21:30.6418622 : MWDEVICE_VIDEO_SERVER_CAPTURE: Captured video frame index 1001 with pts 33865544732114
24/07/20 15:21:30.6419119 : VIDEO_SERVER_TRANSCODER_STREAM_SESSION: Decoded video frame index 1001 with pts 33865544933947
24/07/20 15:21:30.6435439 : VIDEO_SERVER_TRANSCODER_STREAM_SESSION: Filtered video frame index 1001 with pts 169327724
24/07/20 15:21:30.6608526 : MWDEVICE_VIDEO_SERVER_CAPTURE: Captured video frame index 1002 with pts 33865544932106
24/07/20 15:21:30.6609842 : VIDEO_SERVER_TRANSCODER_STREAM_SESSION: Decoded video frame index 1002 with pts 33865545133947
24/07/20 15:21:30.6626590 : VIDEO_SERVER_TRANSCODER_STREAM_SESSION: Filtered video frame index 1002 with pts 169327725
24/07/20 15:21:30.6631337 : VIDEO_SERVER_TRANSCODER_STREAM_SESSION: Encoded video frame index 1000 with pts 304789901400 (was 169327723)