Thursday, September 15, 2016

Lightweight video streaming from a Raspberry with h264_v4l2_rtspserver

VLC adds 330Mo to a raspbian distribution just to stream video to the network. This is huge!
Instead there is a smaller solution, with adds "only" a few dozens megabytes of buliding tools (mainly).

It just interfaces the nice standard V4L2 driver and streams it to a RTSP feed (i.e. Real Time Streaming Protocol). This is also very efficient as minimum buffering is done locally, which means faster response time (time lag is "only" 2 seconds, which is decent).

From this answer.
sudo modprobe -v bcm2835-v4l2
git clone
cd h264_v4l2_rtspserver
sudo apt-get install libopus-dev libexpat1-dev libssl-dev libasound2-dev libudev-dev libavahi-client-dev libcurl4-openssl-dev libjs-jquery
cmake .
sudo make install
Then, the RTSP video stream can be accessed from anywhere with:
vlc rtsp://<raspberry>:8554/unicast

Note that ''h264_v4l2_rtspserver'' has a few options to optimize your bandwidth (reducing the network buffering helps also achieving a faster response time):
h264_v4l2_rtspserver --network-caching 300 -H <height> -W <width> -F <fps>

BTW some additional/alternative info for the Raspberry can be found here.