Video Streaming with UV4L
Video streaming from your Pi comes in many flavors. We have covered it here at Raspberry Valley before. Choosing a streaming approach really boils down on what you want to do with the video feed. For security cameras you don't really care about latency and care more about motion detection and taking snapshots: you'll probably want to use something like MotionEye OS for solutions out of the box with great design and features, or a more simple Motion configuration. Alternatively, you might want to try mjpeg streamer to cover good streaming and use a nice interface for your phone or browser.
We were facing issues with latency with the above mentioned solutions, when building robots and navigating around. The delay was easily in seconds, which is not good for video robot control. Enter UV4L from Linux Projects. Low latency and good quality was achieved using this library.
This page describes a simple setup of UV4L on Raspbian Stretch. It's much more than a streaming server, but we will focus only on this part. Please investigate the homepage for many more features. An honorable mention: this article by Mark Zachmann gives you a deep understanding of various streaming approaches. A must read.
The installation process is rather straightforward. Check the links for installing on other Raspbian systems, as mentioned we will focus on installing it on Raspbian Stretch. We will also install all related tools, just in case. Again - consult documentation if you want to follow other scenarios.
- Add the Linux-Projects repository:
curl http://www.linux-projects.org/listing/uv4l_repo/lpkey.asc | sudo apt-key add - echo 'deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/stretch stretch main' | sudo tee -a /etc/apt/sources.list
sudo apt update
- Install UV4L software packages
sudo apt install uv4l uv4l-raspicam uv4l-raspicam-extras
- Finally, install the GUI and the WebRTC shell
sudo apt install uv4l-webrtc
- Done. You can view your video stream on the same network at the following URL:
and the control panel and other features at this URL:
- Your Pi gets stuck after a while: as this article calls it, we get into 'kernel panic'. Same happened to us: increasing GPU memory and making sure we have adequate cooling fixed the problem.
- Stream quality settings and speed are something you need to balance. A good bunch of tips is available at the Raspberry Pi forum: Getting the most out of your V2 camera with UV4L
- You will find a ton of settings for in /etc/uv4l/uv4l-raspicam.conf
Our video streaming articles: