Streaming video on the Raspberry Pi

As part of our OpenROV effort, we are using the Raspberry Pi as the core and the Raspi camera module as the sensor. First task is to get streaming video working!

We want to use full frame H264 encoded video. Ideally at HD resolutions we we’ll try that later.

It seems there is no V4L (video4linux) driver available for the RaspberryPi camera module yet, so you are stuck using the raspivid. described in very good detail how to get gstreamer up and running. We installed Gstreamer1.0 from the repository he links and essentially it worked out of the box!

We added this repository to our /etc/apt/sources.list file:
deb http://vontaene.de/raspbian-updates/ . main

Then we installed the “gstreamer1.0” module with apt-get.

On the pi, we launched gstreamer with this command line (substituting YOUR-PI-IP-ADDRESS for the pi’s IP address):
raspivid -t 999999 -h 720 -w 1280 -fps 25 -b 2000000 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=YOUR-PI-IP-ADDRESS port=5000

On the client, we used the pipeline recommended by the blog:
gst-launch-1.0 -v tcpclientsrc host=YOUR-PI-IP-ADDRESS port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false

I found that my notebook running ubuntu 13.04 (with “stock” gstreamer) did not have the avdec_h264 decoding module, so this is the ffmpeg based pipeline I used under ubuntu to playback the video:
gst-launch-0.10 -v tcpclientsrc host=192.168.1.245 port=5000 ! gdpdepay ! rtph264depay ! ffdec_h264 ! autovideosink

We took “-hf” out of the raspivid command line recommended by the blog linked above since initially we got flipped video. I suspect the driver has changed since that blog entry. We did some measurements of latency using a stopwatch and a camera and got some good results (photos below). Latencies from camera to screen were ~200mS! This is excellent. We had some trouble playing back 1080p resolution on our client computer (an older Ion netbook) using this gstreamer playback pipeline, but the Pi held up fine. Switching to a different machine our latencies were still ~200.

Overall this seemed to work really well and was very easy! Now on to getting servo control to work!

Leave a Reply