04 September, 2013

Streaming H.264 with Logitech C920 and Raspberry PI (with audio)

Here's an excellent article on how to use your Logitech C920 webcam and Raspberry Pi to stream video:

I wanted my video streams to have audio from C920 as well.
To accomplish that, I ended up using the following command line options:

cvlc v4l2:///dev/video0:chroma=h264:width=1280:height=720 :input-slave="alsa://hw:1,0" --sout '#transcode{acodec=a52,ab=32}:http{mux=ts,dst=:8080/st}' -vvv

With these setting stream bit-rate is around 3,5Mbit/s and Raspberry Pi cpu averages around 20% utilisation.


  1. Thanks a lot for you post, it really helped me.
    I use it to store the h264 video + audio coming from my C920 to a local file on my raspberry.

    However, I encouter an issue :
    Every 30 or 45 seconds, the video freezes for about 1 second.
    In the cvlc output I can see many alsa 'overrun' errors.
    But even without the audio the video freezes sometimes.

    I can not figure where does it come from : is it a rpi performance issue ? (but the cpu doesn't seem too high) or is it a problem with the USB transmission ?
    Your help would be very appreciated,


    1. It might be SDcard performance issue.
      What does hdparm -tT /dev/sda output on speed ?

    2. This comment has been removed by the author.

    3. This comment has been removed by the author.

    4. Hi !

      "I use it to store the h264 video + audio coming from my C920 to a local file on my raspberry."
      ==> Could you tell me how did you do to store the stream into a local file ? :-)

      I tried something like this but the output file is really unstable :
      cvlc v4l2:///dev/video0:chroma=h264:width=1280:height=720 :input-slave="alsa://hw:1,0" --sout test.avi -vvv

      Thanks !

    5. You could try cvlc v4l2:///dev/video0:chroma=h264:width=1280:height=720 :input-slave="alsa://hw:1,0" --sout '#transcode{acodec=a52,ab=32}:file{dst=/path/to/your/file.avi}' -vvv

    6. I tried this one too :) But always the same issue : half down of my record is black, and have a lot of pixelization...

      Maybe a power issue ? I'll try with an external powered usb hub and see what happens

  2. I can get Video only to work, but it seems that when I try to add the audio it fails... I get the following message
    [0xfe72e0] main mux warning: late buffer for mux input (37282)
    Any Ideas? Im hoping to use my Raspberry Pi 2 and C920 to monitor our new puppy while its kenneled, video is nice, but if we could hear if he is crying it would be better.

  3. I got the audio working with some work. Rather than repeat myself, here's some [poorly constructed] commentary over here on stack exchange: http://raspberrypi.stackexchange.com/a/54460/52968