Last three frames missing - NvVideoEncoder

Hi Nvidia,

Hope you are doing well. I’m encoding h264 video on a Jetson Tx2 and noticing the last 2-3 frames of each video are missing. I know its the last three frames because I burned frame numbers into each video, and its always the last few (confirmed with ffprobe). Clearly this has to do with how the encoder is being destructed and cleaned up, which currently includes the following steps:

  1. encoder_->output_plane.setStreamStatus(false);
    encoder_->capture_plane.setStreamStatus(false);
    if (is_multithreaded_)
    {
    auto ret = encoder_->capture_plane.waitForDQThread(10000);
    }
  2. close(out_file_fd_);
  3. encoder_->abort();

Is there something wrong with the way I am finishing writing to disk? What order or steps do I need to do to safely write all remaining frames in the output plane to capture plane and finally to disk?

PS: If my video is 150 frames, after step 1 capture plane reports I have 0 data in the capture plane, 153 total queues, and 147 total dequeues.

Hi,
Please check 01_video_encode sample. You can see below code in encoder_capture_plane_dq_callback():

// GOT EOS from encoder. Stop dqthread.
if (buffer->planes[0].bytesused == 0)
{
    cout << "Got 0 size buffer in capture \n";
    return false;
}

You should terminate NvVideoEncoder after receiving EOS in the callback.