How to put nvbuffer fd into h264 encoder?

Hi nvidia:
I get a DMABUF FD from NvBufferTransform, which contain NV12 video data. Then I want to put the FD into h264 encoder ouputplane directly. Can you give me a simple example on how to qBuffer to the encoder outputplane ?


        struct v4l2_buffer v4l2_buf;
        struct v4l2_plane  planes[MAX_PLANES];
        memset(&v4l2_buf, 0, sizeof(v4l2_buf));
        memset(planes, 0, sizeof(planes));
        v4l2_buf.m.planes = planes;

        if (pctx->index < penc->output_plane.getNumBuffers())
            pnvBuffer = new NvBuffer(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, V4L2_MEMORY_DMABUF, 3, planefmts, pctx->index);
            v4l2_buf.index = pctx->index;

            ret = penc->output_plane.dqBuffer(v4l2_buf, &pnvBuffer, NULL, 10);
            if (ret)
                return NULL;

        pnvBuffer->planes[0].fd        = fd_temp;
        pnvBuffer->planes[0].bytesused = 1;

        ret = penc->output_plane.qBuffer(v4l2_buf, pnvBuffer);
        if (0 > ret)


fd_temp is the source FD which contains NV12 video data. My code cause coredump at the first output_plane.qBuffer. Can you give me some advice on how to put the fd_temp into the encoder outputplane as video data input?

Do you use Jetpack 4 or 5? Please share the release version you re using.

My platform is R35.2.1 AGX XAVIER.

We have deprecated NvBuffer APIs on Jetpack 5, so please use NvBufSurface APIs. For video encoding, please refer to 01_video_enode sample. Or can refer to the patch:
How to use v4l2 to capture videos in Jetson Orin r35 Jetpack 5.0 and encode them using a hardware encoding chip - #8 by DaneLLL

And latest Jetpack 5 is 5.1.3. Certain issues are fixed in later releases and it would be great if you can upgrade.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.