I am using a TX2 to receive video from a gigE vision camera that does not support V4L2. The gigE vision camera driver sends me a raw array of bytes containing the pixel values every time a new frame is generated by the camera.
As new frames are received from the camera I would like to use NvVideoEncoder to real time compress the streaming video.
Which example in the Tegra Multimedia API should I use as a starting point?
How do I modify the format of the byte array containing my pixel values that I receive from my gigE camera in order to transform it into a data type that NvVideoEncoder will accept as input?
My camera is 1920x1080 pixels with 8 bit gray values (no color / chrominance). So each time
the gigE vision camera sends me a frame, I get a 2073600 byte buffer of pixels.
Do I need fill in the v4l2_buffer and v4l2_plane with my raw pixel bytes coming from my camera?
struct v4l2_buffer v4l2_buf;
struct v4l2_plane planes[MAX_PLANES];
How do the bytes need to be reordered in order to be compatible with NvVideoEncoder?
I am guessing that I need to append some fake chrominance pixels to the pixel data that gets
put into either the v4l2_buffer or the v4l2_plane. How should this be done?
In the initialization code below, how many capture buffers need to be setup?
// Enqueue all the empty capture plane buffers
for (uint32_t i = 0; i < m_VideoEncoder->capture_plane.getNumBuffers(); i++)
{
struct v4l2_buffer v4l2_buf;
struct v4l2_plane planes[MAX_PLANES];
memset(&v4l2_buf, 0, sizeof(v4l2_buf));
memset(planes, 0, MAX_PLANES * sizeof(struct v4l2_plane));
v4l2_buf.index = i;
v4l2_buf.m.planes = planes;
CHECK_ERROR(m_VideoEncoder->capture_plane.qBuffer(v4l2_buf, NULL));
}
In other words, how is m_VideoEncoder->capture_plane.getNumBuffers() being determined?
In this method call:
ret = m_VideoEncoder->setCapturePlaneFormat(ENCODER_PIXFMT, STREAM_SIZE.width,
STREAM_SIZE.height, 2 * 1024 * 1024);
what are the legal values for the ENCODER_PIXFMT argument?
Also, looking at NvVideoEncoder.h, the last argument is named sizeimage
and is described as,
“Maximum size of the encoded buffers on the capture plane in bytes”
What should this number be for my 1920x1080 image based on however I have to transform
my raw pixel bytes in order to be put inside a v4l2_buffer struct.