1 |
On Monday, 20 July 2020 19:10:17 BST Ashley Dixon wrote: |
2 |
> Hi List, |
3 |
> |
4 |
> A while ago, I made the grave mistake of buying a Logitech C270 webcam |
5 |
> [1], which initially seemed to be well-supported under Linux as a U.V.C.\ |
6 |
> camera [2]. As shown by the following (partial) output of `v4l2-ctl |
7 |
> --list-formats-ext` suggests, the full 720p@30fps is only supported when |
8 |
> using MJPG. |
9 |
> |
10 |
> ioctl: VIDIOC_ENUM_FMT |
11 |
> Type: Video Capture |
12 |
> |
13 |
> [0]: 'YUYV' (YUYV 4:2:2) |
14 |
> [...] |
15 |
> Size: Discrete 1280x720 |
16 |
> Interval: Discrete 0.133s (7.500 fps) |
17 |
> Interval: Discrete 0.200s (5.000 fps) |
18 |
> [...] |
19 |
> |
20 |
> [1]: 'MJPG' (Motion-JPEG, compressed) |
21 |
> Size: Discrete 1280x720 |
22 |
> Interval: Discrete 0.033s (30.000 fps) |
23 |
> Interval: Discrete 0.040s (25.000 fps) |
24 |
> Interval: Discrete 0.050s (20.000 fps) |
25 |
> Interval: Discrete 0.067s (15.000 fps) |
26 |
> Interval: Discrete 0.100s (10.000 fps) |
27 |
> Interval: Discrete 0.200s (5.000 fps) |
28 |
> [...] |
29 |
> |
30 |
> Unfortunately, as per [3], Logitech C-series cameras (among others) |
31 |
> utilise a proprietary extension to the Motion-JPEG format, in which H.264 |
32 |
> data is attached to the various JPEG key and delta frames in the APP0 field |
33 |
> [4], as shown when inspecting the data of any frame ("AVI1" [5]): |
34 |
> |
35 |
> $ ffmpeg -i video.mp4 -vcodec copy %02d.jpg |
36 |
> $ xxd 01.jpg | head -n 1 |
37 |
> |
38 |
> 00000000: ffd8 ffe0 0021 4156 4931 0001 0101 0078 .....!AVI1.....x |
39 |
> ^^^^^^^^^^^^^^^^^^^^^^ |
40 |
> |
41 |
> Thus, FFmpeg (and programs using FFmpeg) seem to have trouble trouble |
42 |
> correctly parsing these MJPG videos, and VLC almost crashes when trying |
43 |
> to play one (although the Firefox integrated mp4 player does fine): |
44 |
> |
45 |
> $ vlc output.mp4 |
46 |
> |
47 |
> [00007f2eec008aa0] main video output error: video output creation |
48 |
> failed [00007f2ee8c0ae50] main decoder error: failed to create video output |
49 |
> |
50 |
> $ ffmpeg -i output.mp4 somethingelse.avi |
51 |
> |
52 |
> [mjpeg @ 0x5611aeee7000] unable to decode APP fields: Invalid data |
53 |
> found when processing input |
54 |
> |
55 |
> Some work was done on libav many years ago, in an effort to provide a |
56 |
> bitstream filter to ffmpeg to properly convert these to JPEG/JFIF images, |
57 |
> however I doubt it's relevant any more [6], especially considering that |
58 |
> Gentoo has removed libav, and the corresponding USE-flag in |
59 |
> `virtual/ffmpeg` is forever-masked [7]. |
60 |
> |
61 |
> To conclude, is there any method of making these Logitech'd MJPG files |
62 |
> play nicely with FFmpeg (and VLC) ? Someone on the aforementioned Stack |
63 |
> Overflow question pointed out that Skype is able to read both the outer |
64 |
> MJPG and inner H.264 streams, however I cannot confirm this myself. So |
65 |
> far, Firefox is the only program which can play these video files, and I do |
66 |
> not want to use that as my primary video-player ! |
67 |
> |
68 |
> I also need to provide these files to some non-technical (Windows) users |
69 |
> at a local College, so I want to make them as portable and |
70 |
> standards-conformant as possible. |
71 |
> |
72 |
> Thanks for any guidance, |
73 |
> Ashley. |
74 |
> |
75 |
> P.S. Other than this, it's an extremely good camera for someone on a budget. |
76 |
> |
77 |
> [1] https://www.argos.co.uk/product/4034924 |
78 |
> [2] https://linux-hardware.org/index.php?id=usb:046d-0825 |
79 |
> [3] https://stackoverflow.com/a/56403628 |
80 |
> [4] |
81 |
> https://en.wikipedia.org/wiki/JPEG_File_Interchange_Format#JFIF_APP0_marker |
82 |
> _segment [5] https://exiftool.org/TagNames/JPEG.html#AVI1 |
83 |
> [6] |
84 |
> https://code.videolan.org/libav/libav/commit/ba83c4bfb55d5c3fc6b3959edb0d3c |
85 |
> da07a70241 [7] |
86 |
> https://gitweb.gentoo.org/repo/gentoo.git/tree/profiles/base/use.mask#n15 |
87 |
|
88 |
I don't have this webcam so I don't know if it will or won't play nicely with |
89 |
Linux, but at least ffmpeg seems to contain the requisite mjpeg codec: |
90 |
|
91 |
$ ffmpeg -hide_banner -codecs | grep mjpeg |
92 |
DEVIL. mjpeg Motion JPEG (encoders: mjpeg mjpeg_vaapi ) |
93 |
D.VIL. mjpegb Apple MJPEG-B |
94 |
D.A.L. adpcm_ima_smjpeg ADPCM IMA Loki SDL MJPEG |
95 |
|
96 |
Again, I don't know what VLC can do with this. :-/ |