5

I've read multiple threads about streaming a Logitech C920 Webcam via raspberry pi with cvlc using basically this command:

cvlc v4l2:///dev/video1:chroma=h264:width=800:height=600 --sout '#standard{access=http,mux=ts,dst=localhost:8080,name=stream,mime=video/ts}' -vvv

Taken the info from this site: https://wiki.matthiasbock.net/index.php/Logitech_C920,_streaming_H.264

When I use this command, I don't get any output with the Logitech C922. VLC fails to get the h264 stream and says that it only gets the YUYV Stream, which is not compliant to the resulting ts stream. (The h264 stream seems to be transported inside the mjpeg stream)

The Problem is also covered in this recent Blog Post: http://w2017.pl/logitech-vlc-ffmpeg-c922-streaming/

Is there some way around that? I already have audio working with

:input-slave="alsa://hw:1,0" --sout '#transcode{acodec=a52,ab=32}'

Thanks for any hints on how and when this will be resolved.

Output of v4l2-ctl --list-formats:

ioctl: VIDIOC_ENUM_FMT
Index       : 0
Type        : Video Capture
Pixel Format: 'YUYV'
Name        : YUYV 4:2:2

Index       : 1
Type        : Video Capture
Pixel Format: 'MJPG' (compressed)
Name        : Motion-JPEG

Output of v4l2-ctl --all:

Driver Info (not using libv4l2):
Driver name   : uvcvideo
Card type     : C922 Pro Stream Webcam
Bus info      : usb-3f980000.usb-1.4
Driver version: 4.4.50
Capabilities  : 0x84200001
    Video Capture
    Streaming
    Extended Pix Format
    Device Capabilities
Device Caps   : 0x04200001
    Video Capture
    Streaming
    Extended Pix Format
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
    Width/Height  : 800/600
    Pixel Format  : 'YUYV'
    Field         : None
    Bytes per Line: 1600
    Size Image    : 960000
    Colorspace    : SRGB
    Flags         :
Crop Capability Video Capture:
    Bounds      : Left 0, Top 0, Width 800, Height 600
    Default     : Left 0, Top 0, Width 800, Height 600
    Pixel Aspect: 1/1
Selection: crop_default, Left 0, Top 0, Width 800, Height 600
Selection: crop_bounds, Left 0, Top 0, Width 800, Height 600
Streaming Parameters Video Capture:
    Capabilities     : timeperframe
    Frames per second: 24.000 (24/1)
    Read buffers     : 0
                     brightness (int)    : min=0 max=255 step=1 default=-8193 value=128
                       contrast (int)    : min=0 max=255 step=1 default=57343 value=128
                     saturation (int)    : min=0 max=255 step=1 default=57343 value=128
 white_balance_temperature_auto (bool)   : default=1 value=1
                           gain (int)    : min=0 max=255 step=1 default=57343 value=0
           power_line_frequency (menu)   : min=0 max=2 default=2 value=2
      white_balance_temperature (int)    : min=2000 max=6500 step=1 default=57343 value=4000 flags=inactive
                      sharpness (int)    : min=0 max=255 step=1 default=57343 value=128
         backlight_compensation (int)    : min=0 max=1 step=1 default=57343 value=0
                  exposure_auto (menu)   : min=0 max=3 default=0 value=3
              exposure_absolute (int)    : min=3 max=2047 step=1 default=250 value=250 flags=inactive
         exposure_auto_priority (bool)   : default=0 value=1
                   pan_absolute (int)    : min=-36000 max=36000 step=3600 default=0 value=0
                  tilt_absolute (int)    : min=-36000 max=36000 step=3600 default=0 value=0
                 focus_absolute (int)    : min=0 max=250 step=5 default=8189 value=0 flags=inactive
                     focus_auto (bool)   : default=1 value=1
                  zoom_absolute (int)    : min=100 max=500 step=1 default=57343 value=100
                      led1_mode (menu)   : min=0 max=3 default=3 value=0
                 led1_frequency (int)    : min=0 max=255 step=1 default=0 value=24
                     brightness (int)    : min=0 max=255 step=1 default=-8193 value=128
                       contrast (int)    : min=0 max=255 step=1 default=57343 value=128
                     saturation (int)    : min=0 max=255 step=1 default=57343 value=128
 white_balance_temperature_auto (bool)   : default=1 value=1
                           gain (int)    : min=0 max=255 step=1 default=57343 value=0
           power_line_frequency (menu)   : min=0 max=2 default=2 value=2
      white_balance_temperature (int)    : min=2000 max=6500 step=1 default=57343 value=4000 flags=inactive
                      sharpness (int)    : min=0 max=255 step=1 default=57343 value=128
         backlight_compensation (int)    : min=0 max=1 step=1 default=57343 value=0
  • And you have updated the firmware ? sudo apt-get install rpi-update raspi-config, sudo rpi-update – MatsK Sep 7 '17 at 22:35
  • yes - newest firmware & up to date system – Gotschi Sep 7 '17 at 22:51
2

The problem is that the C922 does not advertise its H264 stream over UVC whereas the C920 does. This is because Logitech did not want to enable general use of the H264 for the C922, but instead wanted you to buy the camera with something like Skype which knows internally how to get hold of the data. The reason for this peculiar setup was to enable the camera to display high-resolution image previews on the local machine during video-conferencing; compatible applications send the H264 over the network but display the local camera preview using the MJPEG stream.

Technically speaking, the H264 data does come out of the C922, but you have to stream it as MJPEG. It appears that, parsing each MJPEG frame, the H264 is attached to each still image as an JFIF extension packet (e.g. APP1). Check the JFIF specification for details.

If you can parse the MJPEG frame by frame and access the JFIF packets individually (an open source library like libjpeg enables this) then you can get hold of the data.

Given it's a non-standard solution to a non-standard way of streaming H264 from a web camera, for application robustness and future-compatibility with other cameras, I would stick to coding against the C920.

1

You may have to force the stream mode for your camera. First chek if MPEG or H264 is really available : v4l2-ctl --list-formats

Using v4l2-ctl --all you will see the current resolution and pixel Format for your camera.

To define another resolution and/or pixelFormat, use this command :

v4l2-ctl --device /dev/video0 --set-fmt-video=width=1280,height=960,pixelformat=MJPG

Once this command executed, v4l2-ctl --all should show you :

Format Video Capture:

Width/Height : 1280/960

Pixel Format : 'MJPG'

Wich demonstrate that our previous command as correctly worked, and that the camera will output MJPG instead of YUYV. If you see that your camera is back in YUYV format, it may be because you ask for an unsupported format (see v4l2-ctl --list-formats-ext).

Launch your video client, and then run v4l2-ctl --all again.

If you see that your camera is back in YUYV format, it's because VLC rewrite camera parameters, and then it's command-line options should be tweaked to ask for MJPG format.

If your camera is still in MPEG, that means that VLC should have correctly received MJPG stream, and struggle with the h264 decoding part.

Edit : As pointed in your link, "H264 is still there, but is muxed into MJPEG stream (meaning MJPEG is a container with both still frames and H264 encoded video)". So having your camera in MJPG mode seems to be a prerequite.

Now, following w2017's advice, let's try to create a named pipe (is this really different from command-line pipe ? I don't know !):

mkfifo /tmp/video.mpg

Stream the camera in : v4l2-ctl --stream-mmap=3 --stream-to=/tmp/video.avi

And read from this named pipe as it was a video file, with cvlc or omxplayer :

omxplayer /tmp/video.mpg

  • thanks for your suggestion, but it's the driver which keeps me from using h264 - because as i described above the stream is encapsulated in the mjpeg stream. thanks anyway – Gotschi May 31 '17 at 8:33
  • Can you post the result of v4l2-ctl --list-formats and the pixel Format part of the v4l2-ctl --all, for further investigation ? – Technico.top May 31 '17 at 8:44
  • The results don't mean anything as long as V4L cannot access the H264 stream from the cam via the driver. posted them in the original post – Gotschi May 31 '17 at 9:06
  • Added some informations in the answer – Technico.top May 31 '17 at 9:47
  • 1
    Added some notes, your problem is interesting :) – Technico.top Jun 1 '17 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.