Ubuntu 14.04 mjpg_streamer install attempt

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:

Installation:

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:
http://127.0.0.1:8080/?action=stream

To view a single JPEG just call:
http://127.0.0.1:8080/?action=snapshot

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?)

2 thoughts on “Ubuntu 14.04 mjpg_streamer install attempt

  1. Pingback: Streaming USB webcam to the web with motion on Ubuntu 14.04 | Jay's Technical Talk

  2. It is quite likely that your old webcam is perfectly capable of mjpg production (even if struggles with YUV), as the version of mjpg-streamer that you used has a bug that produces exactly those errors. Setting YUV will work (sort of, in your case?). The fork of mjpg-streamer (1) that you mention has a fix committed for the mjpg issue, rather than something that sorts out YUV (although it might also do that, but I have not looked).

    The above to clarify. Also look at “uvcdynctrl -f” (assuming it is installed) to see the available formats.

    (1) https://github.com/jacksonliam/mjpg-streamer

Leave a Reply

Your email address will not be published.