Motion - Webcam Server
You are here: Foswiki>Motion Web>MotionGuide>WebcamServer (13 Oct 2010, RogerDPack)Edit Attach

Webcam Server

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 ppm is set to off.

The webcam_maxrate and webcam_quality 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 webcam_quality is equivalent to the quality level for jpeg pictures.

The webcam_limit 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).

The option webcam_localhost 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.

1. Create a html page in which you will want the streamed picture.

2. In the html page include this code

 <applet code=com.charliemouse.cambozola.Viewer
    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.

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

4. Enable the feature in motion.conf.

You can also view the live webcam stream using MPlayer like this:

mplayer -demuxer lavf http://www.myurl.com:8081/stream.mjpg

Note that the stream.mjpg 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.

-- KennethLavrsen - 12 Apr 2005
Topic revision: r5 - 13 Oct 2010, RogerDPack
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.