mjpegv4l2v4l

Choose yuy2 or MJPEG in V4L


I am implementing a Camera Preview application. I am using V4L and until now I basically use this code> https://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html

In this example, or any other example I found for that matter, I could not find a possibility to change the frame format to MJPEG to get a higher fps rate. Is there a way to tell V4L to use MJPEG instead of YUY2?


Solution

  • Found it, it is actually pretty simple. Just change the pixelformat in the format struct to V4L2_PIX_FMT_MJPEG. So

    format.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
    

    becomes

    format.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;