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

  One Response 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.

 Leave a Reply

(required)

(required)

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=""> <strike> <strong>