Main Menu
Make donations with PayPal!
Donat-o-Meter Stats
May's Goal: $150.00
Due Date: May 31
Gross Amount: $139.00
Net Balance: $131.13
Left to go: $18.87

How to install or upgrade UV4L on Raspbian Wheezy & Raspbian Jessie for Raspberry Pi

The following instructions refers to installing UV4L on the official Raspbian Linux distributions for any flavour of Raspberry Pi (1, 2, 3, Compute Module, etc...). As these installation instructions are updated and improved very frequently, it is suggested to read them from scratch in case of problems and especially whenever a new UV4L module is announced. Important notes about specific use cases of drivers, modules, configurations, etc.. are often added at the end of this page.

UV4L consists of a series of drivers, a Streaming Server and various extensions for the server. Below we will see how to install all the components to get the best from UV4L, with particular focus on the driver for the Raspberry Pi Camera Boards, although all other drivers can be installed similarly.

To install UV4L open a terminal and type the following commands:
$ curl | sudo apt-key add -
Add the following line to the file /etc/apt/sources.list :
deb wheezy main

$ sudo apt-get update
$ sudo apt-get install uv4l uv4l-raspicam
The last two commands will upgrade UV4L to the most recent version, if it's already installed.

If you want the driver to be loaded at boot, also install this optional package:
$ sudo apt-get install uv4l-raspicam-extras
As a convenience, the above package will also provide a service script for starting, stopping or restarting the driver at any time:
$ sudo service uv4l_raspicam restart
When (re)starting the service, uv4l will be instructed to parse the configuration file /etc/uv4l/uv4l-raspicam.conf to get the default values of the driver options. You can edit that file to add, remove or change the default option values. The same service is used at boot.

Now the UV4L core component and the Video4Linux2 driver for the CSI Camera Board are installed. If you occasionally get unexpected errors from the driver, make sure the camera is enabled and enough memory is reserved for the GPU (not less than 128MB is suggested) from this menu:
$ sudo raspi-config
Also consider updating the firmware with the following command:
$ sudo rpi-update
For detailed informations, 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
If you have not installed the optional uv4l-raspicam-extras package (which provides a convenient script for starting uv4l with the settings taken from a configuration file) and want to quicly test uv4l, load it manually:
$ uv4l --driver raspicam --auto-video_nr --width 640 --height 480 --encoding jpeg
and take a JPEG snapshot from the Camera:
$ dd if=/dev/video0 of=snapshot.jpeg bs=11M count=1
For a list of other use cases click here.

To manually terminate a running driver, close all the applications accessing the device and kill the corresponding uv4l process:
$ pkill uv4l
Apart from the driver for the Raspberry Pi Camera Board, the following Streaming Server front-end and drivers can be optionally installed:
$ sudo apt-get install uv4l-server
$ sudo apt-get install uv4l-uvc
$ sudo apt-get install uv4l-xscreen
$ sudo apt-get install uv4l-mjpegstream
$ sudo apt-get install uv4l-dummy
for which the manual pages are available:
$ man uv4l-server
$ man uv4l-uvc
$ man uv4l-xscreen
$ man uv4l-mjpegstream
$ man uv4l-dummy
Starting from Raspberry Pi 2 on, the WebRTC extension for the Streaming Server is also available:
$ sudo apt-get install uv4l-webrtc
Note that some browsers will no longer allow WebRTC over HTTP for security reasons. If you want or need to enable secure HTTPS in the Streaming Server instead, you must provide a password-less private key and a valid certificate via the --ssl-private-key-file and the --ssl-certificate-file server options. A private key and a self-signed certificate can be generated as follows:
$ openssl genrsa -out selfsign.key 2048 && openssl req -new -x509 -key selfsign.key -out selfsign.crt -sha256
Once you have installed and eventually configured the HTTP/HTTPS Streaming Server module as shown above, make sure to reload uv4l for it to notice and start the server. Afterwards you can access the server with the browser at the default address and port http://raspberry:8080/ (where raspberry has to be replaced with the actual hostname or IP address of your RaspberryPi and the protocol can be either http or https).

Thanks to the WebRTC extension mentioned above, it's also possible to broadcast both live audio and video contents from the Raspberry Pi 2 to all the participants or viewers joining a room of a Jitsi Meet Conference on the Web. Furthermore, no browser and no GUI will have to be used on the Raspberry Pi. For this to be possible, it's necessary to install the additional xmpp-bridge service, which will be automatically started once the installation has finished or when the system boots:
$ sudo apt-get install uv4l-xmpp-bridge
Note: by default WebRTC gets the audio stream from the default installed soundcard, which generally is the first indexed card shown by arecord -l. If you want to make use of an USB soundcard by default in Raspbian Wheezy, edit /etc/modprobe.d/alsa-base.conf and modify or add the following lines and reboot the system:
options snd-usb-audio index=0
options snd_bcm2835 index=1
In Raspbian Jessie edit or create /etc/asound.conf and insert:
pcm.!default {
type asym
playback.pcm "plug:hw:0"
capture.pcm "plug:dsnoop:1"
where "0" is usually the index of the default sound card embedded in the Raspberry Pi that will be used for playback, while "1" usually corresponds to the index of the USB sound card that will be used for capture. After you have rebooted, make sure capture volumes are unmuted and increased to the desired level. alsamixer is an handful tool for this purpose.

Note for the UVC driver users: since recent versions of UV4L, there should be no longer need to manually load the driver to use your camera. After you have rebooted for the first time, it's enough to plug in or unplug the device to have it recognized by a system script and have uv4l loaded or unloaded automatically. If you have installed the UV4L Streaming Server, the default port it will be listening to is specified in the configuration file (e.g. /etc/uv4l/uv4l-uvc.conf). All this will only work for one UVC-based device plugged in at most at the same time - which is the common case. Unfortunately, from the second UVC camera onwards the system script is not smart enough: as it will read the same configuration file, the new Streaming Server instances will try to use the same port again, which might result in a conflict with the first running instance.

Return to Sections Index Return to Sections Index
[ Back to UV4L, Userspace Video4Linux framework | Return to Sections Index | Printer Friendly Page]


Lost Password?

Register now!