Mar 102013
 

I’ve had a few queries regarding streaming audio as well as video on the Raspberry Pi, so tonight I set up my little Raspberry Pi with a Logitech C110. This webcam also has a microphone integrated which the Pi can use to record audio.
Everything has been setup as per part 3 of my ffmpeg streaming guide.

A little investigation reveals which hardware device the microphone is recognised as.

# arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: C110 [Webcam C110], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

So the device is recognised as card 1. This comes in later when we are setting up the audio part of the streaming.

I’ve updated the webcam.sh script to reflect the fact that we are now recording sound –

ffserver -f /root/ff.conf & ffmpeg -vcodec mjpeg -v verbose -r 15 -s 176x128 -f video4linux2 -i /dev/video0 -f alsa -ac 1 -i hw:1 http://localhost:81/webcam.ffm

And I also need to update ff.conf with the new streaming settings
The Stream webcam section has now turned into this –
<Stream webcam.avi>
Feed webcam.ffm
Format avi
VideoSize 176x128
VideoFrameRate 15
VideoBufferSize 40
VideoBitRate 64
AudioBitRate 32
AudioChannels 1
AudioSampleRate 11025
VideoQMin 1
VideoQMax 20

With this configuration, I could start ffmpeg with audio and video streaming. However I could not get my laptop with vlc to connect to it for now, so I’ll have to keep investigating that.
Hopefully this helps though.


Please support the continued development of any useful scripts and tutorials that you have found useful !




Share

  7 Responses to “Quickie : Streaming Audio And Video From A Webcam On The Raspberry Pi”

  1. I have had a row in the same direction, tried to get a webcam (Microsoft LifeCam HD-5000) stream audio and video at the same time.
    First attempt was to use FFMPEG, but I had always only audio or video. Here it was depending on the order of the input what would die – i.e.:
    this would result in a file with a couple of initial frames video, then the video stream drops and we have audio only
    ffmpeg -vcodec mjpeg -v verbose -r 15 -s 176×128 -f video4linux2 -i /dev/video0 -f alsa -ac 1 -i hw:1 sample.avi

    this would result in a file with a couple of seconds audio, then the audio stream drops and we have video only
    ffmpeg -vcodec mjpeg -v verbose -f alsa -ac 1 -i hw:1 -r 15 -s 176×128 -f video4linux2 -i /dev/video0 sample.avi

    I decided to drop ffmpeg and turn to mjpg-streamer (http://www.tanzilli.com/video_streaming)
    Here I decided to stream the audio stream via a independent mp3 stream – here a similarity arose.
    The stream that has been initiated last is the one surviving. Starting the video stream and then initiating alsa stream from the MIC abended the video stream and very often restarting the video stream would drop strange errors. pulling info with v4l2-clt would say that the camera does respond incorrectly.

    I worked with downscaled streams to see if there is a upper limit of speed on the USB port, but I have a strong feeling that this is not a bottleneck issue.

    No solution yet found – but hope to save you a bit troubleshooting with the info.

    • hello, I just met the same problem.
      Thanks for sharing!
      So is there any solution now?
      Thanks very much!

      I will try both methods on my camera Logitch C110, hoping one maybe work

    • ps: I just tried
      ffmpeg -vcodec h264 -v verbose -f alsa -ac 1 -i hw:1 -r 30 -s 176×128 -f video4linux2 -i /dev/video0 sample.avi

      It work on my Pi. the audio is good, but the real fps is about 12. It is at least a video…
      And the audio and the video don’t match (video has a ~3 seconds delay )

      OS: RSPB DEBIAN
      Camera: Logetich C110

      • ffmpeg -vcodec h264 -v verbose -f alsa -ac 1 -i hw:1 -r 30 -s 176×128 -f video4linux2 -i /dev/video0 sample.mpg

        this try is perfect, fps could be 30.
        But the audio and video still don’t match. (~1s delay)

        • Thanks for all your efforts testing !
          I believe that you can set an audio offset with ffmpeg. perhaps that will help ?

  2. I am a student and I want some help with a project that I am working on. To b honest I know very little about RBpi. I want to connect my Android phone with the raspberry pi through the built-in WiFi on the raspberry pi.
    And though that I with to stream video on my android phone of a USBcam attached with raspberry .
    Kindly please help me on this problem.
    Regards,

    • I have a guide on how to get Motion running on the Raspberry Pi. Follow that, then you can use the app TinyCam Monitor on an Android device to view the webcam.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

This site uses Akismet to reduce spam. Learn how your comment data is processed.