TX2 VideoEncoder setIFrameInterval not working

Hi guys, I’m playing with the 10_camera_recording sample, in the encoderCapturePlaneDqCallback function, I check for I-frame and print log like this:

v4l2_ctrl_videoenc_outputbuf_metadata meta;
thiz->m_VideoEncoder->getMetadata(v4l2_buf->index, meta);
if (meta.KeyFrame) {
    printf("XXPXX got key frame %ld \n", currentTimeMs());
}

It turns out no matter what I pass for setIFrameInterval, the I-frame interval is almost 1 second.

The output looks like this:

XXPXX got key frame 1585099353203
XXPXX got key frame 1585099354213
XXPXX got key frame 1585099355213
XXPXX got key frame 1585099356213
XXPXX got key frame 1585099357213

It seems always 30 frames, if I input with 30fps, the I-frame interval is 1 second, if I input with 15fps, the I-frame interval is 2 seconds, if I input with 60fps, the I-frame interval is 0.5 second, no matter what I set through setIFrameInterval and setFrameRate.

Hi,
Please check the two functions in NvVideoEncoder.h

    /**
     * Sets the encoder I-frame interval.
     *
     * Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID
     * \c V4L2_CID_MPEG_VIDEO_GOP_SIZE. Must be called after setFormat on both
     * the planes and before \c requestBuffers on any of the planes.
     *
     * @param[in] interval Interval between two I frames, in number of frames.
     *
     * @return 0 for success, -1 otherwise.
     */
    int setIFrameInterval(uint32_t interval);

    /**
     * Sets the encoder IDR interval.
     *
     * Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID
     * #V4L2_CID_MPEG_VIDEO_IDR_INTERVAL. Must be called after setFormat on both
     * the planes and before \c requestBuffers on any of the planes.
     *
     * @param[in] interval Interval between two IDR frames, in number of frames.
     *
     * @return 0 for success, -1 otherwise.
     */
    int setIDRInterval(uint32_t interval);

And check IDR/I frame interval through JM decoder.
http://iphome.hhi.de/suehring/tml/

Hi @DaneLLL, thanks for your reply! setIDRInterval works fine!