Nvdec via V4L2: how to flush frames to capture plane

I am trying to implement code which decodes small chunks of H264 video, 15 frames at at a time. These chunks of video start with a keyframe and then have a sequence of p-frames after that. I am using NVDec via V4L2. After queuing this data to the output plane, I want to read the output frames from the capture plane before writing the next chunk of data to the output plane.

  • If I simply try to dequeue a frame from the capture plane after the chunk of video is queued to the output plane, I get an EAGAIN error and then the next atttempt to dequeue blocks indefinitely.
  • If I queue an empty buffer to the output plane after the buffer with the chunk of video, then I am able to read the 15 frames from the capture plane but I don’t know how to restart the decoder to send more video.
  • If I call v4l2_ioctl with VIDIOC_DECODER_CMD and command V4L2_DEC_CMD_STOP on the output plane, I don’t get any error but this does not seem to make any difference. (4.5.1. Memory-to-Memory Stateful Video Decoder Interface — The Linux Kernel documentation).

I am running Jetpack 6.1 on an Orin.