Solution for error 22 and invalid argument in v4l2

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.