2010-03-21

mjpg-streamer documentation

The documentation for mjpg-streamer is kind of scattered about.  I have dumped it all here for my own convenience.

Usage introduction

This example shows how to invoke mjpg-streamer from the command line

export LD_LIBRARY_PATH="$(pwd)"
./mjpg_streamer -o "output_http.so -w ./www"

pwd echos the current path you are working at, the backticks open a subshell to execute the command pwd first the exported variable name configures ldopen() to search a certain folder for *.so modules

export LD_LIBRARY_PATH=`pwd`

This is the minimum command line to start mjpg-streamer with webpages for the input-plugin default parameters are used

./mjpg_streamer -o "output_http.so -w `pwd`/www"

To query help for the core:
./mjpg_streamer --help

To query help for the input-plugin "input_uvc.so":
./mjpg_streamer --input "input_uvc.so --help"

To query help for the output-plugin "output_file.so":

./mjpg_streamer --output "output_file.so --help"

To query help for the output-plugin "output_http.so":
./mjpg_streamer --output "output_http.so --help"

To specify a certain device, framerage and resolution for the input plugin:

 ./mjpg_streamer -i "input_uvc.so -d /dev/video2 -r 320x240 -f 10"

To start both, the http-output-plugin and write to files every 15 second:

mkdir pics
./mjpg_streamer -o "output_http.so -w `pwd`/www" -o "output_file.so -f pics -d 15000"

To protect the webserver with a username and password (!! can easily get sniffed and decoded, it is just base64 encoded !!)

./mjpg-streamer -o "output_http.so -w ./www -c UsErNaMe:SeCrEt"

If you want to track down errors, use this simple testpicture plugin as input source. To use the testpicture input plugin instead of a webcam or folder:

./mjpg_streamer -i "./input_testpicture.so -r 320x240 -d 500" -o "./output_http.so -w www"

Usage: mjpg_streamer

mjpg_streamer
  -i | input "<inputplugin.so> [parameters]"
  -o | output "<outputplugin.so> [parameters]"
 [-h | help ]........: display this help
 [-v | version ].....: display version information
 [-b | background]...: fork to the background, daemon mode

Note: If you start mjpg-streamer in the background use this to stop it:
kill -9 `pidof mjpg_streamer`

Example #1:
 To open an UVC webcam "/dev/video1" and stream it via HTTP:
  mjpg_streamer -i "input_uvc.so d /dev/video1" -o "output_http.so"

Example #2:
 To open an UVC webcam and stream via HTTP port 8090:
  mjpg_streamer -i "input_uvc.so" -o "output_http.so -p 8090"

Example #3:
 To get help for a certain input plugin:
mjpg_streamer -i "input_uvc.so help"

In case the modules (=plugins) can not be found:
 * Set the default search path for the modules with:
   export LD_LIBRARY_PATH=/path/to/plugins,
 * or put the plugins into the "/lib/" or "/usr/lib" folder,
 * or instead of just providing the plugin file name, use a complete
   path and filename:
   mjpg_streamer i "/path/to/modules/input_uvc.so"

Parameters for input_uvc.so

This is the output from:
  #mjpg_streamer --input "input_uvc.so --help"

The following parameters can be passed to this plugin:

 [-d | --device ].......: video device to open (your camera)
 [-r | --resolution ]...: the resolution of the video device,
                          can be one of the following strings:
                          QSIF QCIF CGA QVGA CIF VGA
                          SVGA XGA SXGA
                          or a custom value like the following
                          example: 640x480
 [-f | --fps ]..........: frames per second
 [-y | --yuv ]..........: enable YUYV format and disable MJPEG mode
 [-q | --quality ]......: JPEG compression quality in percent
                          (activates YUYV format, disables MJPEG)
 [-m | --minimum_size ].: drop frames smaller then this limit, useful
                          if the webcam produces small-sized garbage frames
                          may happen under low light conditions
 [-n | --no_dynctrl ]...: do not initalize dynctrls of Linux-UVC driver
 [-l | --led ]..........: switch the LED "on", "off", let it "blink" or leave
                          it up to the driver using the value "auto


11 comments:

Walter said...

Super! Thx!

PS: vor Ubuntu users use this doc

http://wiki.ubuntuusers.de/MJPG-Streamer

Anonymous said...

How can I use mjpg_streamer with two webcams at the same time?

AndyfromTucson said...

I have no idea if you can use two cameras at once; I am no expert

ryosaeba said...

i've used mjpeg-streamer with 3 cameras at once. just find out the individual /dev/video0, /dev/video1 and /dev/video2, run 3 instances of mjpeg-streamer with 3 different http ports.

T3CHKOMMIE said...

I really liked your post. I was wondering how the -L parameter worked? i cant seem to get the IR leds turned on on my hercules webcam. everything else seems to work but the LEDS. thanks!

AndyfromTucson said...

I have never tried to get the -l to work.

Janis Alnis said...

MJPG-STREAMER works great, but would it be possible to add audio like USTREAM does.

Many Webcams from Logitech have a microphone built in. I

I am Using Debian on non Intel boards without graphic interface(Foxboard, NanosG20, Beagleboard). Can not run Windows there.

Tried different stremacast programms, could not get them working. Probably because of noncompatibility with Intel processor.
So would be happy if someone could help with adding audio to mjpg-streamer.

Bernhardt said...

Hi What webcam did you use?

My webcams only provide YUV output and it uses a lot of CPU power to convert it to MJPEG.

AndyfromTucson said...

I used an HP Deluxe Webcam, HP Product No. KQ246AA

oscar said...

Thanks Andy for the info. When mjpg_streamer runs on my RPi, it prints a lot of messages out .. example "UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device mapping control for Pan/tilt Reset" and seems to want an "enter" from the keyboard to finish. Do you know how to fix that, I can't add another command after that in a startup script.

Todd said...

I've created a fork of mjpg-streamer which handles mulitple cameras with the input_uvc plugin. You provide a comma delimited list of devices and a port, and it transmits video from whichever one is active. Sending commands to the socket switches the cameras.

https://github.com/atomicpunk/mjpg-streamer