Raspberry Pi Camera

Usage
Currently, there are are two options for getting video out of the Raspberry Pi camera:


 * 1) The raspivid application
 * 2) The V4L2 interface (beta)

The v4l2 interface can be useful for applications that only have that input options. For applications that can read input from file the raspivid application might be better because it provides more complete control over the camera and compressor parameters.

The following sections describe how we can use the. The starting point is a stock raspbian image with the camera interface enabled.

Install VLC
VLC is available through the raspbian repositories: $ sudo apt-get install vlc

RTSP with VLC
Start never ending server at 1280x720 30 frames per second, and 4.5 Mbps: $ raspivid -n -w 1280 -h 720 -b 4500000 -fps 30 -vf -hf -t 0 -o - | \ cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:9000/}' :demux=h264

On the client side: $ cvlc rtsp://192.168.1.110:9000/

CPU load:
 * ref. load: 6% CPU
 * 0 clients: 25% CPU
 * 1 clients: 35% CPU
 * 2 clients: 45% CPU

HTTP with VLC
Server: $ raspivid -n -w 1280 -h 720 -b 4500000 -fps 30 -vf -hf -t 0 -o - | \ cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:9000}' :demux=h264

Client: $ cvlc http://192.168.1.110:9000/

I observed very poor video quality (pixelated) at client end.

CPU load:
 * 0 clients: 25%
 * 1 clients: 33%

Install Gstreamer
Raspbian is still stuck with gstreamer-0.10, which would be sufficient for streaming need; however, gstreamer-1.0 contains OMX support and can be installed from third party repository.

Edit /etc/apt/sources.list and add the line: deb http://vontaene.de/raspbian-updates/. main

Then in a terminal: $ sudo apt-get update $ sudo apt-get install gstreamer1.0

We can then use the bonecam tricks as described in the following sections.

Gstreamer using RTP/UDP
Server: $ raspivid -n -w 1280 -h 720 -b 4500000 -fps 30 -vf -hf -t 0 -o - | \ gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=10 pt=96 ! \     udpsink host=192.168.1.101 port=9000

Client: $ gst-launch-1.0 -v udpsrc port=9000 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! \     rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false


 * Performance: 42% CPU with or without client (non-overclocked raspi)
 * 4.7 Mbps network traffic
 * Good quality
 * Very low latency

Gstreamer using RTP/TCP
More robust protocol but with a non-negligible traffic overhead.

Server: $ raspivid -n -w 1280 -h 720 -b 4500000 -fps 30 -vf -hf -t 0 -o - | \ gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=10 pt=96 ! \     udpsink host=192.168.1.101 port=9000

Client: $ gst-launch-1.0 -v udpsrc port=9000 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! \     rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false


 * Performance:
 * 0 clients: 29% CPU
 * 1 clients: 54% CPU
 * 2 clients: 75% CPU
 * 5.1 Mbps network traffic
 * Good quality
 * Very low latency

Recording the video while streaming
One of the desired functions for the HEAT 2X mission is to record the video locally for post-mission review in case of successful recovery. There are two obvious options:


 * 1) Use a multiudpsink and usae a local client to record to disk.
 * 2) Use a tee element in the server flow graph.

The multiudpsink option overloads the raspi. The tee option works very well with a CPU load below 50%:

$ raspivid -n -w 1280 -h 720 -b 4500000 -fps 30 -vf -hf -t 0 -o - | \ gst-launch-1.0 -v fdsrc ! h264parse ! tee name=splitter ! \     queue ! rtph264pay config-interval=10 pt=96 ! udpsink host=192.168.1.101 port=9000 \ splitter. ! queue ! filesink location="videofile.h264"