How to get the NvBuffer from the fd?

I am extending jetson multimedia “10_Camera_recording” example with a NvBufferTransform for the video resolution conversion once the buffer is received from the Camera Source.
I have created the Transform Out FD using the ret = NvBufferCreateEx(&out_dmabuf_fd, &output_params);

output_params.width = 640;
output_params.height = 480;
output_params.layout = NvBufferLayout_Pitch;
output_params.payloadType = NvBufferPayload_SurfArray;
output_params.nvbuf_tag = NvBufferTag_VIDEO_CONVERT;
output_params.colorFormat = NvBufferColorFormat_NV12;

Once the Transform is done, “NvBufferTransform(dmabuf_fd, out_dmabuf_fd, &transform_params)” , I would like to pass the updated buffer to “m_VideoEncoder->output_plane.qBuffer(v4l2_buf, dmabuf)”

but to pass I need the “dma buffer” of the “out_dmabuf_fd”. Can someone help me here to get the NvBuffer from the fd?

I need to enque the lower resolution buffer to the encoder.


Please refer to this patch:

You can queue the buffers like:

+                // Push the frame into V4L2.
+                enc_buf.m.planes[0].m.fd = fd;
+                enc_buf.m.planes[0].bytesused = 1; // byteused must be non-zero
+                ctx->enc->output_plane.qBuffer(enc_buf, NULL);