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

  -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


Scripter said...

Super! Thx!

PS: vor Ubuntu users use this doc


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

Anonymous 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.


Unknown said...

Hello, and thank you in advance for your help.
I am working on the cam rover project as outlined in magpie magazine. (raspberry pi) I am trying to install
However, when I run the “make” command I get a fatal error: “videodev.h no such file no such directory. “ I have tried all the fixes that I have found as well as asked for help on the raspberry Pi home page and the source forge, Tom says he recalls the error. But not the fix, I have gone so fare as to down load a new O.S. run the updates and the upgrades and try the install and it still crashed with the same error at the same spot. I am thinking either I am doing something dumb or they have up graded there Software? I have also tried to install tried to install the mjpg-streamer_94-i386.deb but I can’t seem to get that to extract correctly. (grrrrrr) the link in the article points to the r63 file that dies on the “make’ command.
Thank you all very much.

Anonymous said...

The fix for videodev.h is to change all occurrences to videodev2.h. input_gspcav1 did not compile after this so i removed it from my setup.


Anonymous said...

Hi there,

Thanks for the tutorial, it's easy and working! Literally saved my life yesterday, when after a day of coding only the streaming left unsolved on my rover.
BTW: everybody is building 'rovers'?! :D

Also i have a question, since i have/had only an old Genius webcam around for the testing:
With the defualt mjpeg mode of the streamer i get no image, while it's working with YUY. But with the YUY it's still generating around 60%-80% CPU load, while the video feed is lagging. Also need to mention that i was achieved this with lower resolutions like 320x240 or beside a more crappy stream 640x480.
With a true MJPEG webcam can i achieve some more nice results? maybe even with some lower loads?
Theoretically i should, but first need to make sure :)

Unknown said...

Hello , very usefull my friend, just a question, is there some way to begin the streaming connection from the openwrt box to an external server ? similar than udp works with vlc. It woould be great since my openwrt box is behind nat with no static public ip.