Streaming the Raspberry Pi Camera


Using UV4L for Streaming

User space Video4Linux (UV4L) is a set of tools and drivers which can be installed on Linux machines to provide various media capabilities such as video streaming.

Follow the instructions on this page to install UV4L:

Official UV4L Installation Page

Be sure to follow the instructions for your particular distribution flavor, such as Wheezy, Jessie, or Stretch. Installing for the wrong flavor will cause problems, often resulting in errors related to public keys, unsigned repository, etc.

For convenience, the steps for Stretch are listed below. If you have problems, visit the above page and follow the official instructions as they do change.

Installation for Stretch

  • at command prompt> curl http://www.linux-projects.org/listing/uv4l_repo/lpkey.asc | sudo apt-key add –
  • add this line to /etc/apt/sources.list: deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/stretch stretch main
  • at command prompt> sudo apt-get update
  • at command prompt> sudo apt-get install uv4l uv4l-raspicam
  • at command prompt> sudo apt-get install uv4l-raspicam-extras

Controlling the Service

The last command above installs extra tools which load the driver at boot and allow it to be stopped, started, and restarted at any time.

When (re)starting the service, uv4l will be instructed to parse the configuration file /etc/uv4l/uv4l-raspicam.conf to get the default values for the driver and the server options. You can edit that file to add, remove or change the default values, then use this command to restart the driver to use the new settings:

at command prompt> sudo service uv4l_raspicam restart

Solving Errors

If the driver generates occasional errors, try reserving more memory for the GPU:

at command prompt> sudo raspi-config

choose Advanced Options, then Memory Split, then enter the desired value (no less than 128 MB)

Also try updating the firmware:

at command prompt> sudo rpi-update

For detailed information, options, etc… about the modules installed type accordingly:

$man uv4l
$man uv4l-raspicam

To get the list of all available options:

$uv4l --help --driver raspicam --driver-help

Quick Test

To take a jpg test shot:

$dd if=/dev/video0 of=Documents/snapshot.jpeg bs=11M count=1

Installing the Streaming Server

$sudo apt-get install uv4l-server uv4l-uvc uv4l-xscreen uv4l-mjpegstream uv4l-dummy uv4l-raspidisp

Running the Streaming Server:

$uv4l --auto-video_nr --driver raspicam --encoding mjpeg --server-option '--port=9000'

With a password:

$uv4l --auto-video_nr --driver raspicam --encoding mjpeg --server-option '--port=9000' --server-option '--admin-password=myp4ssw0rd!'
,

Leave a Reply

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