nvh264dec / vah264dec add one frame of latency on a no-B-frame live stream, even with max-display-delay=0

We stream live H.264 over WebRTC (webrtcbin) at 30 fps and are trying to bring glass-to-glass latency down. Almost all of the remaining receiver time is in the hardware decoder: nvh264dec holds each decoded frame for one frame period before pushing it downstream. Software decoders on the same stream don’t do this.

Setup

  • GStreamer 1.24.2, Ubuntu, NVIDIA GPU: [GPU model / driver version]

  • Sender: x264enc tune=zerolatency speed-preset=ultrafast key-int-max=30 pass=cbr byte-stream=true. No B-frames, so the stream needs no reordering.

  • Receiver: webrtcbin → rtph264depay → decodebin (picks nvh264dec) → videoconvert/glupload → qml6glsink

  • 1080p, 30 fps, progressive

    The nvh264dec time is about one frame period, 33.3 ms at 30 fps. Decode itself is fast. The frame is complete and decoded long before it is pushed out.

    What we tried

    • max-display-delay=0 on nvh264dec: no change.

    • compliance settings: no change.

    • Checked the SPS: num_reorder_frames = 0, and no B-frames are present.

      Our understanding of why

      From GST debug logs, the output seems to be driven by the GstH264Decoder base class DPB “bumping” logic, not by nvh264dec itself. With a DPB size of 1 and num_reorder_frames = 0, the decoded picture is a reference picture, and it stays in the DPB until the next picture needs the slot. It is only output then. So every frame leaves when the next frame arrives, which is one frame period late. max-display-delay doesn’t seem to affect this path.

      The software decoders (avdec_h264, openh264dec) don’t use GstH264Decoder, which would explain why they don’t show the delay.

      We also read the 1.28 release notes (through 1.28.8) and didn’t find a change to this behaviour.

      Questions

      1. Is this understanding right, or are we missing a setting? For example, is there a low-latency or “output as soon as decoded” mode for GstH264Decoder-based decoders?
      2. For a stream that signals num_reorder_frames = 0 (or max_dec_frame_buffering), could the base class output the picture immediately while still keeping it as a reference?

You can use the latency tracer to locate what component causes this extra latency. Use gst-stats-1.0 to process the logs and make human readable output.

Typically, many things can introduce 1 frame of latency, Annex B formatting is out, lack of marker bit over RTP is another (though would affect avdec_h264). Regarding NVDEC, considering we had 4 frames with the stateful interface, you already won on latency quite a bit. But I know on VA (with Intel and AMD), for the type of stream you produce, there shouldn’t be any decoder introduce latency other then the processing time.