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