What is the difference between these two pixel formats in v4l2 API:
V4L2_PIX_FMT_JPEG
and V4L2_PIX_FMT_MJPEG
?
To me it seems that both should return JPG images when packets are read from a webcamera.
What is the difference between these two pixel formats in v4l2 API:
V4L2_PIX_FMT_JPEG
and V4L2_PIX_FMT_MJPEG
?
To me it seems that both should return JPG images when packets are read from a webcamera.
I am interested in this question as well and I hope somebody can post an answer with some detail. Perhaps my observations below are useful to find an answer.
I noticed that there are some differences between the two settings.
The PI Noir camera (which I use on a Raspberry Pi 1 B) supports both formats, as can be seen by using
v4l2-ctl --list-formats
. If I use MJPG pixel format, the framerate is higher (around 30 fps) and the bytes 6,7,8,9 (indexed from 0) of each frame are 'J','F','I','F'. If I use JPEG, the framerate is lower (around 6 fps) and the same bytes are 'E','x','i','f'.My logitech c910 supports MJPEG, but not JPEG, as seen from
v4l2-ctl --list-format
. However both pixel formats can be set with no error via C++. The images contain 'A','V','I','1' in those bytes. I cannot view them using an image viewer, but firefox and chrome browsers display them correctly. If I open them as video files from VLC I can also view them. If I use JPEG as pixel format, it also works and I get the same type of images.