I tried installing mjpg_streamer on Ubuntu 14.04 to allow me to stream a USB webcam over the internet (or your local network) to web browsers or other IP based systems that read mjpeg streams.
The nice thing about mjpg_streamer is that if your webcam can deliver a mjpeg stream, it will turn around and stream it over the web using very little CPU power for transcoding.
Unfortunately, my old Philips webcam does not generate an MJPEG stream, and the video format it does generate isn’t quite compatible to even allow mjpg_streamer to display a good image. But what I tried is documented below:
sudo add-apt-repository ppa:altair-ibn-la-ahad/mjpg-streamer
sudo apt-get update
sudo apt-get install mjpg-streamer
Trying to figure out where the www files are:
dpkg-query -L mjpg-streamer
The README file tells me that you have to make your own…or just use the following URLs directly (replacing 127.0.0.1 with the IP address of the server if your server is different from the localhost):
To view the stream use VLC or Firefox and open the URL:
To view a single JPEG just call:
Then I found out that the image served by my webcam by default had errors….
/?action=stream” cannot be displayed because it has errors
Due to the fact that it didn’t produce motion-jpeg streams directly, and instead produced raw (not quite YUV) streams, so I had to add a “-yuv” option to the input plugin.
I figured this out by reading the ‘documentation’ for the input plugin here.
mjpg_streamer -i "input_uvc.so --help"
This produced an image, but the colors were all off (very green) and the image showed duplicate images which means that the web cam isn’t exactly producing the correct YUV format that mpjg_streamer is expecting. I believe an experimental branch of mpjg_streamer may be supporting this, but I didn’t want to install from source, so I switched over to trying to use motion instead.
Here is my final command line running it (on your first USB webcam), default streaming (to port 8080).
mjpg_streamer -i "input_uvc.so -yuv -d /dev/video0" -o "output_http.so"
Commands to clean things up:
sudo apt-get remove mjpg-streamer
sudo add-apt-repository --remove ppa:altair-ibn-la-ahad/mjpg-streamer
I went on to use the “motion” program to transcode into mjpg format and stream the webcam’s output over HTTP. (It also detects motion and saves local snapshots of motion frames as a side effect / extra feature?)