With a cheap web camera that connects to USB video streaming can be done in just a few easy steps, with a Raspberry PI . The simplicity of the solution comes from the streaming technology used effectively. Everything happens over HTTP , so you can watch the Webcam on any device that surfs the web.
Basically, the Raspberry PI will be running a mini web server that serves as a video information file M-JPG ( Motion Jpeg , more info here ). In short, an M-JPG is actually a set of images and you just see one after the other, just like the frames of a movie. The advantage of M-JPG -s is that it does not require plug-ins or browser extensions for rendering. A simple element HTML type IMG , with the desired size and source attribute set to M-JPG ‘s served will allow the webcam to render in a web page.
Installing The Required Software
The entire solution is based on the server MJPG-streamer whose page can be found here . The program was written by Tom Stöveken and licensed GPLv2. Calin Crisan has compiled and prepared a version of this program for the Raspberry PI .
- Make sure you have an updated version of the operating system on Raspberry PI .
- Install the package libv4l-0 , available in the Raspbian distribution:
sudo apt-get install libv4l-0
- Connect the webcam to the USB device. We assume here that you have bought a webcam compatible with Linux , in order to confirm this, look for /dev/video0 .
cd /dev/ ls | grep video
If you can’t see the webcam, then the webcam does not have a driver for Linux or it will require additional adjustments to work – the subject does not cover that eventuality (Sorry!).
- Download the script MJPG-streamer-rpi.tar.gz directly to your Raspberry PI
It does not really matter where you download the script, and no root permissions are required to run the script either.
- Rename the file you have just downloaded, and unzip it
mv get?download=36:mjpg-streamer-rpi mjpg-streamer-rpi.tar.gz tar -zxvf mjpg-streamer-rpi.tar.gz
- Start the server by executing ./MJPG-homestreamer.sh current directory.
cd mjpg-streamer ./mjpg-streamer.sh start
- If everything went well, launch your favourite browser and type http://raspberrypi:8080/?action=stream (where raspberrypi’s is your device’s address). You should see the image captured by the webcam.
- The current version of Chrome has a problem directly playing this sort of file, so try FireFox , if the picture is does not refresh.
- If the system does not work, look at the the file MJPG-streamer.log for any errors.