Error: pixel format not supported
Error 22, invalid argument
My camera comes with a laptop. The following figure is displayed with the command lsusb:
Bus 002 device 003: Id 17ef: 4808 Lenovo
Many people have encountered this problem because the encoding adopted is incompatible with the encoding supported by the device.
Taking my environment as an example, the encoding format I set in the Code is:
FMT. FMT. pix. pixelformat = v4l2_pix_fmt_yuv420
You can use the function to return the pixel format supported by the device:
IOCTL (FD, vidioc_enum_fmt, & fmt1)
Struct v4l2_fmtdesc FMT; int ret; memset (& FMT, 0, sizeof (FMT); FMT. index = 0; FMT. type = v4l2_buf_type_video_capture; while (ret = IOCTL (FD, vidioc_enum_fmt, FMT) = 0) // view the encoding format {FMT. index ++; printf ("pixelformat is '% C % C', description is' % s' \ n", FMT. pixelformat & 0xff, (FMT. pixelformat> 8) & 0xff, (FMT. pixelformat> 16) & 0xff, (FMT. pixelformat> 24) & 0xff, FMT. description );}
This code is returned.
Pixelformat is 'yuyv', description is 'yuv (yuyv )'
Put the above
FMT. FMT. pix. pixelformat = v4l2_pix_fmt_yuv420
Change to FMT. FMT. pix. pixelformat = v4l2_pix_fmt_yuyv. However, you need to understand that the encoding formats of yuv420 and yuyv are different, and the subsequent bitstream processing needs to be changed accordingly.
Pass