Questions on sample 15_multivideo_encode

Hello,
I have several questions on the sample 15_multivideo_encoder, please see below:

  1. In ctx.enc->capture_plane.waitForDQThread (-1), why the argument is -1?
  2. In encoder_capture_plane_dq_callback() function, which subfunction perform the dequeue action?
  3. In encoder_capture_plane_dq_callback() function, it seems the encoded stream(NALU) is in NvBuffer *buffer object, right? And what’s the difference between v4l2 buffer and Nvbuffer in this function?

Hi,
The implementation is open source:

/usr/src/jetson_multimedia_api/samples/common/classes/NvV4l2ElementPlane.cpp
/usr/src/jetson_multimedia_api/samples/common/classes/NvBuffer.cpp

Please take a look.

  1. -1 is to set infinite wait. You can set to different value in millisecond. Please check
int
NvV4l2ElementPlane::waitForDQThread(uint32_t max_wait_ms);
  1. Please check implementation in
void *
NvV4l2ElementPlane::dqThread(void *data);
  1. NvBuffer class is more like an extension of struct vl42_buffer. Please follow the sample code to get pointer and size of encoded frames.

Thank you very much.
I still have several questions for you,

  1. In NvBufferTransform( src_dmabuf_fd, dest_dmabuf_fd, *transform_params), the dest_dmabuf_fd will holds the converted video pixel data, can I use NvV4l2ElementPlane::qBuffer() to queue the dest_dmabuf_fd into the Nvencoder output plane? Or could you tell me how to queue this dest_dmabuf_fd into the encoder output plane?
  2. It seems the encoder output plane only supports mplane format, so does it mean that we can’t use single plane format to capture v4l2 cameras?

Hi,
Yes, you can queue NvBuffer to NvVideoEncoder directly. For v4l2 source, you can take a look at 12_camera_v4l2_cuda + this patch:
TX2 Camera convert/encode using Multimedia API issue - #17 by DaneLLL

Hi DaneLLL,
Thank you very much for your reply.
Another question for you: the process for encoder output plane is that first dequeue the buffer, second fill the dequeued buffer the converted data, third queue the buffer, right?

Hi,
If there is no buffer in queue you would need to queue buffers first. Please refer to the code:

+                // Check if we need dqBuffer first
+                if (bufferIndex < OUTPLANE_BUFNUM &&
+                    ctx->enc->output_plane.getNumQueuedBuffers() <
+                    ctx->enc->output_plane.getNumBuffers())
+                {
+                    // The queue is not full, no need to dqBuffer
+                    // Prepare buffer index for the following qBuffer
+                    enc_buf.index = bufferIndex;
+                    // Create Render buffer
+                    if (-1 == NvBufferCreateEx(&fd, &input_params))
+                        ERROR_RETURN("Failed to create NvBuffer");
+                    outplane_fd[bufferIndex] = fd;
+                    bufferIndex++;;
+                }
+                else
+                {
+                    // Output plane full or max outstanding number reached
+                    ctx->enc->output_plane.dqBuffer(enc_buf, &buffer, NULL, 10);
+                    fd = enc_buf.m.planes[0].m.fd;
+                }

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