Compile MJPG-Streamer from Source on Ubuntu 11.10

Instead of downloading an old .deb package and installing it using sudo dpkg -i mjpg-streamer you can also just get the source, compile and run:

sudo apt-get install libjpeg-dev subversion imagemagick
cd ~/Downloads/
svn co https://mjpg-streamer.svn.sourceforge.net/svnroot/mjpg-streamer mjpg-streamer
cd mjpg-streamer/mjpg-streamer
make clean all

To try a first start, run:

export LD_LIBRARY_PATH=.
./mjpg_streamer -i "input_uvc.so" -o "output_http.so -w ./www"

and go to http://127.0.0.1:8080.

If you like to install it (so all users can easily use it):

sudo make DESTDIR=/usr install

Using different resolution / Using the optimal resolution with a Logitech 9000 Pro

Source: http://www.quickcamteam.net/devices/logitech_uvc_frame_format_matrix.xls The available resolutions are:

  • YUV2
    • 1600x1200 5 fps
    • 960x720 10 fps
    • 800x600 25 fps
    • 640x480 30 fps
    • 352x288 30 fps
    • 320x240 30 fps
    • 176x144 30 fps
    • 160x120 30 fps
  • MJPG
    • 960x720 15 fps
    • 800x600 30 fps
    • 640x480 30 fps
    • 352x288 30 fps
    • 320x240 30 fps
    • 176x144 30 fps
    • 160x120 30 fps

So choose 1600x1200 and let mjpg-streamer do the MJPEG conversion (high CPU load):

./mjpg_streamer -i "input_uvc.so -d /dev/video0 -y -r 1600x1200" -o "output_http.so -w ./www"

or choose 960x720 and use the hardware MJPEG compression of the Logitech 9000 Pro (low CPU load):

./mjpg_streamer -i "input_uvc.so -d /dev/video0 -f 15 -r 960x720" -o "output_http.so -w ./www"

A script to start mjpg-streamer:

#!/bin/bash
RESOLUTION="960x720"
FRAMERATE="15"
MJPG_WEB_ROOT="/home/philipp/Downloads/mjpg-streamer/mjpg-streamer/www"
PORT="8081"

mjpg_streamer -i "input_uvc.so -d /dev/video0 -f $FRAME_RATE -r $RESOLUTION" -o "output_http.so -w $MJPG_WEB_ROOT -p $PORT"

Securing the Stream with HTTP AUTH

export LD_LIBRARY_PATH=.
./mjpg_streamer -i "input_uvc.so -d /dev/video1 -f 15 -r 800x600" -o "output_http.so -w ./www -c uSeRnAmE:s3cure-pAssw0rd"

Playing M-JPEG stream with mplayer

mplayer -fps 30 -demuxer lavf "http://127.0.0.1:8080/?action=stream&ignored.mjpg"

It might be necessary to configure mplayer to prefer IPv4 instead of IPv6 Edit ~./mplayer/config and add or change the option: prefer-ipv4=yes.

Tray Icon

Untested: https://gist.github.com/1582986 (From http://forum.ubuntuusers.de/topic/webcam-im-tray-mit-mjpg-streamer/).

Resources

Comments