Raspberry Pi – Webcam Streaming

Streaming an external cam

Several options exist to stream the picture of a webcam or the Raspberry Pi cam from the  Pi. The first is using a MJPEG stream. This is the most compatible as many applications and even browsers can display such a stream.

The second one is H264. Also H264 can be encoded on the Pis GPU it has a very high latency, at least five seconds from my experience.

And last but not least you can simply pipe the video stream over netcat to transmit it to another client.

1. Motion

“Motion” can serve up a MJPEG stream. Apart from that is has several other features as listed below: eg. a simple motion detection. It may run in the background as Linux daemon. Here’s a guide how to get motion going with a PS3 Eye Cam.

  • Taking snapshots of movement
  • Watch multiple video devices at the same time
  • Watch multiple inputs on one capture card at the same time
  • Live streaming webcam (using multipart/x-mixed-replace)
  • Real time creation of mpeg movies using libraries from ffmpeg
  • Take automated snapshots on regular intervals
  • Take automated snapshots at irregular intervals using cron
  • Execute external commands when detecting movement (and e.g. send SMS or email)
  • Motion tracking (camera follow motion – special hardware required)
  • Feed events to a MySQL or PostgreSQL database.
  • Feed video back to a video4linux loopback for real time viewing
  • Lots of user contributed related projects with web interfaces etc.
  • User configurable and user defined on screen display.
  • Control via browser (older versions used xml-rpc)
  • Automatic noise and threshold control
  • Motion is a daemon with low CPU consumption and small memory footprint.

2. With MJPEG streamer.

A nice guide how to build and run the open source MJPEG streamer on the pi by Miguel Grindberg.

2. As a H264 Stream with VLC via RTSP

Install VLC Player on the Pi. VLC will act as the streaming server.

sudo apt-get install vlc

Run raspivid and pipe the videostream into vlc for streaming.

raspivid -o - -t 0 -n -vf -hf -w 1280 -h 720 -fps 25 -g 100 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/,mux=ts}' :demux=h264

you can now display the stream in VLC using rtsp://[Raspberry IP]l:8554/as your address.

Leave a Reply

Your email address will not be published. Required fields are marked *

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