Streaming video with a Raspberry PI and a Logitech C270

Submit to reddit

Hi,

I wanted to setup a live webcam using a Raspberry Pi (model B, first rev. with 256M RAM) so after checking and happily finding out that my camera is suported I went along. First I installed the support packages:

1
sudo apt-get install gstreamer-tools gstreamer0.10-plugins-bad gstreamer0.10-plugins-good v4l-utils

After that I wrote a small script that would start the stream:

1
2
3
4
5
6
7
8
9
10
#!/bin/bash
# set below your Raspberry PI IP address
myip="192.168.xxx.xxx"
port="5000"

gst-launch
-v v4l2src !
"image/jpeg,width=1280,height=720,framerate=30/1" !
multipartmux !
tcpserversink host=$myip port=$port sync=false

Save this to a script and set it to start on boot (if you want).

After the stream is running you could check it with VLC for example:

1
vlc tcp://192.168.xxx.xxx:5000

Notes:

  • I got my inspiration from here (the author also has a simple android app for viewing the stream)
  • Yes, I can stream HD with low CPU usage (it starts to hickup after running 7 clients)
  • I couldn’t get audio to work. Maybe it has something to do with this camera as CPU usage is very low. The source blog has details on how to enable audio but I couldn’t get it to work
  • I tried using ffmpeg (if you want audio support remember to install libasound2-dev before compiling ffmpeg) but audio still didn’t work
  • The camera would randomly fail after a few minutes and gstreamer would crash. Because I didn’t want to use a powered USB hub I bridged the polyfuses as described here. If you have the newer rev. 2 (with 512M RAM) that might not be necessary. Do note that this PI has no keyboard, wi-fi dongle or video out and uses a 2A power supply. Now the stream remains stable.
  • Chuantong Huang

    gstreamer1.0-pulseaudio — can it work??