V4L2 difference between JPEG and MJPEG pixel forma

2019-08-14 12:41发布

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.

标签: v4l2
1条回答
做个烂人
2楼-- · 2019-08-14 13:00

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.

查看更多
登录 后发表回答