Copying from NvBufferTransform directly to output_plane fd

Hi im trying to color convert a video stream and encode it with x264. The code works if I copy the data after NvBufferTransform with NvBufferMap and then from that buffer to the output_plan of the encoder. Since this operation takes quite some time, I was wondering if I can color convert the image directly into the output_plane fd of the encoder. A shortend version of the programm looks like:

 NvBuffer* buffer;
 ctx.enc->output_plane.dqBuffer(v4l2_buf, &buffer, NULL, 10);
 int fd = buffer->planes[0].fd;
 int ret = NvBufferTransform(tctx.in_dmabuf_fd, fd, &tctx.transform_params); 
 ret = ctx.enc->output_plane.qBuffer(v4l2_buf, NULL);

The qBuffer functions blocks after around 10 calls which indicates that the encoder is not encoding the image. What am I’m doing wrong?


For using hardware encoder, you can set output plane to DMA buffer mode and call NvBufferTransform () to copy data into the buffers. Please refer to 01_video_encode sample.

The issue was that bytes_used need to be set in the output_plane. Otherwise the encoder does not start. However I found that the fastest way of color converting images is width kernels. NvBufferTransform is quite slow compared to that.