Motion has simple webcam server built in. The video stream is in mjpeg format.
Each thread can have its own webcam server. If you enable the webcam server (option webcam_port to a number different from 0) and you have more than one camera, you must make sure to include webcam_port in each thread config file and set webcam_port to different and unique port numbers or zero (disable). Otherwise each webcam server will use the setting from the motion.conf file and try to bind to the same port. If the webcam_port numbers are not different from each other Motion will disable the webcam feature.
Note: The webcam server feature requires that the option
is set to off
options are important to limit the load on your server and link. Don't set them too high unless you only use it on the localhost or on an internal LAN. The option
is equivalent to the quality level for jpeg pictures.
option prevents people from loading your Network connection by streaming for hours and hours. The options defines the number of picture frames sent as mjpeg Motion will allow without re-connecting (e.g. clicking refresh in the browser).
is a security feature. When enabled you can only access the webserver on the same machine as Motion is running on. If you want to present a live webcam on your web site this feature must be disabled.
The webserver generates a stream in "multipart jpeg" format (mjpeg). You cannot watch the stream with most browsers. Only certain versions of Netscape works. Mozilla and Firefox brosers can view the mjpeg stream but you often have to refresh the page once to get the streaming going. Internet Explorer cannot show the mjpeg stream. For public viewing this is not very useful. There exists a java applet called Cambozola
which enabled any Java capable browser to show the stream. To enable the feature to a broad audience you should use this applet or similar.
To use the webcam feature with Cambozola is actually very simple.
Create a html page in which you will want the streamed picture.
In the html page include this code
archive=cambozola.jar width="320" height="240" style="border-width:1; border-color:gray; border-style:solid;"> <param name=url value="http://www.myurl.com:8081"> </applet>
Where the width and height is the image size of the video stream.
Replace www.myurl.com:8081 by the real url and port number of your choice.
In the same directory you place the cambozola.jar file. No need to build the java applet from source. Simply use the applet in the package.
Enable the feature in motion.conf.
You can also view the live webcam stream using MPlayer
mplayer -demuxer lavf http://www.myurl.com:8081/stream.mjpg
Note that the
part is important, without it you will get a
LAVF_check: no clue about this gibberish!
error from libavformat.
Note that you can stream from multiple videos by having several applet viewers on each page (pointed to different url's, of course).
These are the special webcam parameters.
- 12 Apr 2005