Hi List,

A while ago, I made the grave mistake of buying  a  Logitech  C270  webcam  [1],
which initially seemed to be well-supported under Linux as a U.V.C.\ camera [2].
As shown by the following  (partial)  output  of  `v4l2-ctl  --list-formats-ext`
suggests, the full 720p@30fps is only supported when using MJPG.

        ioctl: VIDIOC_ENUM_FMT
                Type: Video Capture

                [0]: 'YUYV' (YUYV 4:2:2)
                        [...]
                        Size: Discrete 1280x720
                                Interval: Discrete 0.133s (7.500 fps)
                                Interval: Discrete 0.200s (5.000 fps)
                        [...]

                [1]: 'MJPG' (Motion-JPEG, compressed)
                        Size: Discrete 1280x720
                                Interval: Discrete 0.033s (30.000 fps)
                                Interval: Discrete 0.040s (25.000 fps)
                                Interval: Discrete 0.050s (20.000 fps)
                                Interval: Discrete 0.067s (15.000 fps)
                                Interval: Discrete 0.100s (10.000 fps)
                                Interval: Discrete 0.200s (5.000 fps)
                        [...]

Unfortunately, as per [3], Logitech C-series cameras (among  others)  utilise  a
proprietary extension to the Motion-JPEG format, in which H.264 data is attached
to the various JPEG key and delta frames in the APP0 field [4],  as  shown  when
inspecting the data of any frame ("AVI1" [5]):

        $ ffmpeg -i video.mp4 -vcodec copy %02d.jpg
        $ xxd 01.jpg | head -n 1

        00000000: ffd8 ffe0 0021 4156 4931 0001 0101 0078  .....!AVI1.....x
                       ^^^^^^^^^^^^^^^^^^^^^^

Thus, FFmpeg (and programs using FFmpeg) seem to have trouble trouble  correctly
parsing these MJPG videos, and VLC  almost  crashes  when  trying  to  play  one
(although the Firefox integrated mp4 player does fine):

        $ vlc output.mp4

        [00007f2eec008aa0] main video output error: video output creation failed
        [00007f2ee8c0ae50] main decoder error: failed to create video output

        $ ffmpeg -i output.mp4 somethingelse.avi

        [mjpeg @ 0x5611aeee7000] unable to decode APP fields: Invalid data found
        when processing input

Some work was done on libav many years ago, in an effort to provide a  bitstream
filter to ffmpeg to properly convert these to JPEG/JFIF images, however I  doubt
it's relevant any more [6],  especially  considering  that  Gentoo  has  removed
libav, and the corresponding USE-flag in `virtual/ffmpeg` is forever-masked [7].

To conclude, is there any method of making  these  Logitech'd  MJPG  files  play
nicely with FFmpeg (and VLC) ?  Someone on  the  aforementioned  Stack  Overflow
question pointed out that Skype is able to read both the outer  MJPG  and  inner
H.264 streams, however I cannot confirm this myself. So far, Firefox is the only
program which can play these video files, and I do not want to use  that  as  my
primary video-player !

I also need to provide these files to some non-technical (Windows)  users  at  a
local College, so I want to make them as portable  and  standards-conformant  as
possible.

        Thanks for any guidance,
        Ashley.

P.S. Other than this, it's an extremely good camera for someone on a budget.

[1] https://www.argos.co.uk/product/4034924
[2] https://linux-hardware.org/index.php?id=usb:046d-0825
[3] https://stackoverflow.com/a/56403628
[4] 
https://en.wikipedia.org/wiki/JPEG_File_Interchange_Format#JFIF_APP0_marker_segment
[5] https://exiftool.org/TagNames/JPEG.html#AVI1
[6] 
https://code.videolan.org/libav/libav/commit/ba83c4bfb55d5c3fc6b3959edb0d3cda07a70241
[7] https://gitweb.gentoo.org/repo/gentoo.git/tree/profiles/base/use.mask#n15

-- 

Ashley Dixon
suugaku.co.uk

2A9A 4117
DA96 D18A
8A7B B0D2
A30E BF25
F290 A8AA

Attachment: signature.asc
Description: PGP signature

Reply via email to