Hi, I have tried using the tegra mutimedia API sample application 12 to receive the video in UYVY format from the camera. The video is receiving fine. I have verified it by storing one frame. Then to encode the video, I have converted this in to YUV420M using the NvBufferTransform API. I have recorded the video using the following piece of code
static bool
save_yuv420(int dmabuf_fd)
{
NvBufferParams params = {0};
void *sBaseAddr[3] = {NULL};
int ret = 0;
int size;
unsigned i;
int file;
file = open(“/home/nano/yuv420.yuv”, O_CREAT | O_WRONLY | O_APPEND | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
ret = NvBufferGetParams (dmabuf_fd, ¶ms);
if (ret != 0)
ROS_ERROR(“%s: NvBufferGetParams Failed \n”, func);
for (i = 0; i < params.num_planes; i++) {
ret = NvBufferMemMap (dmabuf_fd, i, NvBufferMem_Read_Write, &sBaseAddr[i]);
if (ret != 0)
ROS_ERROR(“%s: NvBufferMemMap Failed \n”, func);
ret = NvBufferMemSyncForCpu (dmabuf_fd, i, &sBaseAddr[i]);
if (ret != 0)
ROS_ERROR("%s: NvBufferMemSyncForCpu Failed \n", __func__);
size = params.height[i] * params.pitch[i];
if (-1 == write(file, sBaseAddr[i],size))
ROS_ERROR("Error in yuv420 writing");
// }
ROS_INFO(“yuv420 size: %d, %d,%d”,params.height[i], params.width[i], params.pitch[i]);
ret = NvBufferMemSyncForDevice (dmabuf_fd, i, &sBaseAddr[i]);
if (ret != 0)
ROS_ERROR(“%s: NvBufferMemSyncForDevice Failed \n”, func);
ret = NvBufferMemUnMap (dmabuf_fd, i, &sBaseAddr[i]);
if (ret != 0)
ROS_ERROR("%s: NvBufferMemUnMap Failed \n", __func__);
}
return true;
}
But, the recorded frame is showing only lines. What is the issue here, any help?
I have tried by integrating the sample 07 video converter to convert the UYVY to YUV420M again the video is full of lines. I am attaching the video for your reference. Please check![yuv420_issue|690x388]
(upload://rl8jRq7QVx7Uf6OP8WVp62WtvB8.jpeg)
Input image: UYVY 4192 * 3120