A user guide written for "normal" people. Nerds are welcome, too.
Editor: Kenneth Lavrsen
Original
URL for this document. http://www.lavrsen.dk/sources/webcam/motion_guide.htm
Version:
2.2 (for motion 3.1.14), 2004 May 20, 17:30
Change history in the bottom of this document.
Upgraders should read
the section 'Upgrading From Older Version'.
Motion is a program that monitors the video signal from one or more cameras
and is able to detect if a significant part of the picture has changed. Or in
other words, it can detect motion.
The program is written in C and is made
for the Linux operating system.
Motion is a command line based tool. It has
absolutely no graphical user interface. Everything is setup either via the command
line or via a set of configuration files (simple ASCII files that can be edited
by any ASCII editor).
The output from motion can be:
Motion is an open source type of project. It does not cost anything. Motion is published under the GNU GENERAL PUBLIC LICENSE (GPL) version 2 or later. It may be a bit difficult to understand all the details of the license text (especially if your first language is not English). It means that you can get the program, install it and use it freely. You do not have to pay anything and you do not have to register anywhere or ask the author or publisher for permission. The GPL gives you both rights and some very reasonable duties when it comes to copying, distribution and modification of the program. So in very general terms you do not have to worry about licensing as a normal hobby user. If you want to use Motion in a commercial product, if you want to distribute either modified or original versions of Motion - for free or for a fee, you should read the license carefully. For more information about free software and the GPL, I encourage you to study the very interesting documents about the subject available the of the Free Software Foundation pages about the Philosophy of the GNU Project.
Both Motion and the Motion Guide are written by people that do all this as a hobby and without asking for any payments or donations. We have a life other than developing Motion and its documentation. This means that bugfixes and updates to this guide are done as our time and families allow it. You are however encouraged to participate and contribute in a very active mailing list. It is a list with a very "positive attitude" and with many contributors that propose features, post patches, discuss problems and patiently answer newbie questions with a very positive spirit. Expect 1-10 emails per day.
To get motion direct your browser to the Motion Homepage.
Under the download page you will find a series of stable versions and a series of development versions.
Motion was originally written by Jeroen Vreeken who still actively participates
in the development of Motion and later Folkert van Heusden continued with as
a lead programmer with Kenneth Lavrsen responsible for Motion Guide, website
and releases on Sourceforge.
From version 3.1.12 Motion is now project managed
entirely by Kenneth Lavrsen, and the project now shift towards being developed
by many contributers.
For support we encourage you to join the mailing list
instead of writing to Jeroen, Folkert or Kenneth directly. We are all very active
on the mailing list and by using the mailing list much more users will have
benefit of the answers. Newbies and stupid questions are welcome on the list.
Contributions in the form of patches are also very welcome on the mailing list.
Development has stopped on the 3.0 branch. Latest release on this branch
was 3.0.7-1. This branch is no longer being actively
developed and lacks many nice features.
From version 3.1.13 (Motion Guide
version 2.0) no longer supports the 3.0 branch. There is a motion_guide that
fits 3.0.7-1 in the distribution package if you wish to still use the old version.
Currently the community is working on the 3.1.X branch which is actually quite stable also but with some new features that are not fully refined. If the latest is not working try the 3.1.10 and install the "Webcam Stream Timeout" patch which removes the worst known bugs.
Within few weeks the current 3.1 X branch will be frozen as a stable 3.2 and experimental development will continue on a 3.3 branch.
Version 3.1.13 tries to both address some user wishes and tries to simplify the user interface. This also means deleting, renaming and adding new options. This has been necessary since the config option suite has grown ad-hoc over the years and it had become time to clean things up a bit.
See more description at the Motion Homepage.
You can find more information and links at the Motion Homepage.
Using Motion with Net cameras such as Axis:
Users on the mailing
list have reported that certain versions of the CURL library (lib curl) do not
work with Motion. If you CURL version 7.9.X you may run into problems.
Reports indicates that curl >=7.10 and < v7.10.8 should work fine.
Motion is distributed as source files that you must compile yourself.
The short overview of the steps to install Motion.
Before you start you may need to install a number of shared libraries
that Motion uses. If they are missing the feature will simply normally not
be included. Most of these libraries can be found on the CDs of your distribution.
A few will have to be downloaded from the Internet. Note that when you install
software using pre-compiled binaries (RedHat type RPMs, Debian debs etc)
you normally only get what is needed to run the programs themselves. In
order to compile other programs from source that uses these pre-compiled
libraries you also need to installed the development packages. These are
normally called the same name as the package suffixed by -devel or -dev.
These development packages contains the header files (xxx.h) that Motion
needs to build with the shared libraries. If you build a library from sources
you already have these header files. It is recommended to simply install
the pre-compiled binary packages and their development brothers.
This
is a list of shared libraries used by Motion and the RPM packages that provides
them.
Motion will always need these libraries to be built and work
Library |
RPM Packages |
Debian Packages |
libm, libresolv, libdl, libpthread, libc, ld-linux, libcrypt, and libnsl |
glibc and glibc-devel |
libc6 , libc6-dev ,libglib1.2 |
libjpeg |
libjpeg and libjpeg-devel |
libjpeg62 and libjpeg62-dev ( optional libjpeg-mmx-dev ) |
libz |
zlib and zlib-devel |
zlib1g and zlib1g-dev |
If you need to connect to a Network Camera you need these libraries:
Library |
RPM Packages |
Debian Packages |
libcurl |
curl and curl-devel |
curl, libcurl2 and libcurl-dev |
libssl and libcrypto |
openssl and openssl-devel |
libssl0.9.6, libssl-dev and openssl |
libgssapi_krb5, libk5crypto, and libcom_err |
krb5-libs |
libkrb53 |
For generating mpeg films with ffmpeg you need this library:
(See also
the section 'Generating MPEG films with ffmpeg' for how to install ffmpeg and
libavcodec)
Library |
RPM Packages |
Debian Packages |
libavcodec |
ffmpeg and ffmpeg-devel or install from source! |
ffmpeg ,libavcodec1,libavcodec1-dev (*) |
(*) Debian doesn't provide deb packages for ffmpeg due patent issues. So you can build yourself from source or from Christian Marillat website or apt repository.
deb http://marillat.free.fr/ unstable main deb ftp://ftp.nerim.net/debian-marillat/ stable main # ( woody ) deb ftp://ftp.nerim.net/debian-marillat/ testing main # ( sarge ) deb ftp://ftp.nerim.net/debian-marillat/ unstable main # ( sid )Add the suitable line to your /etc/apt/sources.list and run this:
apt-get update ; apt-get -y install ffmpeg libavcodec1 libavcodec1-dev
For using XML-RPC remote control of Motion you need this library:
(See
also the section 'Controlling Motion via xml-rpc' for how to install xmlrpc-c)
Library |
RPM Packages |
Debian Packages |
libxmlrpc |
xmlrpc-c and xmlrpc-c-devel or install from source! |
libxmlrpc-c0 , libxmlrpc-c0-dev , libwww-dev (for -lwwwzip ) |
For logging in MySQL you need this library:
Library |
RPM Packages |
Debian Packages |
libmysqlclient |
mysql and mysql-devel |
libmysqlclient10 and libmysqlclient10-dev |
For logging in PostgreSQL you need this library:
Library |
RPM Packages |
Debian Packages |
libpq |
postgresql-libs and postgresql-devel |
postgresql-dev and libpgsql2 |
Configure is script that you run to setup the build environment for the C-compiler. It generates the "Makefile" which the program "make" uses to compile and install the software.
To run configure your current directory must be the motion directory. You
type
./configure
You can add the parameter ./configure --help to get help
on the different switches.
This is walk through of the options. The configure script used is based on another configure scripts and contains some not very interesting switches.
Option |
Description |
Editors comment |
-h, --help |
display this help and exit |
|
--help=short |
display options specific to this package |
This command shows the options special to motion. Recommended |
--help=recursive |
display the short help of all the included packages |
|
-V, --version |
display version information and exit |
Gives no useful information |
-q, --quiet, --silent |
do not print `checking...' messages |
Not very useful. Output to screen is only a few lines anyway. |
--cache-file=FILE |
cache test results in FILE. [disabled] |
No function |
-C, --config-cach |
alias for `--cache-file=config.cache' |
No function |
-n, --no-create |
do not create output files |
Used for testing if other switches produce error - without writing anything to the disk |
--srcdir=DIR |
find the sources in DIR. [configure dir or `..'] |
DIR is a directory path. Editor recommends having the current directory being the motion installation directory and not using this switch. Then it defaults to the same directory as where the configure script is which is the current directory. |
Installation directories: |
||
--prefix=PREFIX |
install architecture-independent files in PREFIX |
The default /usr/local means that the executable
binary "motion" is installed in /usr/local/bin, the manual
page in /usr/local/man/man1, the document files in /usr/local/docs/motion-version,
configuration file in /usr/local/etc, and some examples config files
in /usr/local/examples/motion-version |
--exec-prefix=EPREFIX |
install architecture-dependent files in EPREFIX [PREFIX] |
If you set this it only defines an alternative
installation directory for the executable binary. |
--bindir=DIR |
user executables [EPREFIX/bin] |
With this option you can control exactly in which directory the executable binary is installed. The previous option automatically adds the bin directory. Here you are in fill control. |
--sbindir=DIR |
System admin executables [EPREFIX/sbin] |
Not used by motion. Ignore it. |
--libexecdir=DIR |
program executables [EPREFIX/libexec] |
Not used by motion. Ignore it. |
--datadir=DIR |
read-only architecture-independent data [PREFIX/share] |
Not used by motion. Ignore it. |
--sysconfdir=DIR |
read-only single-machine data [PREFIX/etc] |
This is where motion both installs the default
configuration file and also where it later searches for it.
Editor recommends leaving this at default. Be careful if you run "make install" again. This will overwrite the motion.conf file that you have edited and experimented with for hours. Make sure to keep a copy in a safe place. Alternatively, copy the working file to the motion base install directory. Then make install will simply copy the same file back again. |
--sharedstatedir=DIR |
modifiable architecture-independent data [PREFIX/com] |
Not used by motion. Ignore it. |
--localstatedir=DIR |
modifiable single-machine data [PREFIX/var] |
Not used by motion. Ignore it. |
--libdir=DIR |
object code libraries [EPREFIX/lib] |
Not used by motion. Ignore it. |
--includedir=DIR |
C header files [PREFIX/include] |
Not used by motion. Ignore it. |
--oldincludedir=DIR |
C header files for non-gcc [/usr/include] |
Not used by motion. Ignore it. |
--infodir=DIR |
info documentation [PREFIX/info] |
Not used by motion. Ignore it. |
--mandir=DIR |
man documentation [PREFIX/man] |
Editor recommends the default. |
Optional Packages: |
||
--with-libavcodec=DIR |
Specify the path for the directory in which you
find the libavcodec.so or libavcodec.a (part of ffmpeg) If not specified configure will search in /usr/lib and /usr/local/lib |
DIR is the location of the libavcodec directory
in the FFmpeg package. |
--without-libavcodec |
Do not compile with ffmpeg |
Use this if you do not want to compile with ffmpeg. If ffmpeg is not installed you do not need to specify that Motion must build without ffmpeg. |
--with-mysql=DIR |
normally, configure will scan all possible default installation paths for mysql. When its fail, use this command to tell configure where mysql installation root directory is. |
DIR is the installation directory of mysql. E.g.
/usr/local/mysql |
--without-mysql |
Do not compile with MySQL support |
Use this if you do not want to include MySQL support
in the package. |
--with-pgsql=DIR |
Include PostgreSQL support. DIR is the PostgreSQL
base install directory, defaults to /usr/local/pgsql. |
Default is that make searches in the normal installation
directories of most distributions. |
--without-pgsql |
Do not compile with PostgreSQL support |
Use this if you do not want to include PostgreSQL
support in the package. |
Not much to say about this. When you run make, all the C-source files are
automatically compiled and linked. Just look out for error messages.
Make
uses a file called "Makefile" which is generated by the "configure"
script you just ran. If you have special needs you can manually edit this file.
Next time you run configure a new Makefile will be generated and your changes
are lost.
If you have run make before, you should run a "make clean" before
running make again. This cleans out all the output files that were generated
the previous time you ran make. On other words:
First time you build motion
run configure, make, make install. If you need to build it again (to run with
different configure options) run configure, make clean, make, make install.
"Make install" simply copies all the nice files that were generated
during the compilation/linking that make did.
Makes the directories (if they do not already exist): /usr/local/bin, usr/local/man/man1, /usr/local/etc, /usr/local/doc/motion-3.1.X, /usr/local/doc/motion-3.1.X, and /usr/local/examples/motion-3.1.X.
Copies the following files from the base motion directory (assuming the default PREFIX /usr/local was used when running configure - otherwise adjust to the actuals you chose)
Note that the any existing files are overwritten. Pay attention to your configuration file motion.conf. You may not want this overwritten. Keep a copy in a safe place before you run "make install". Editor recommend renaming the motion.conf in the source code directory after the very first installation. This way you will not accidentally overwrite the real motion.conf file.
From the motion base installation directory you simply run make uninstall
And delete the base installation directory in /usr/local and any link pointing to it. If you have forgotten where you installed it or someone else did it for you, simply search for the files and directories starting with motion. If the filenames and the directories match the names described in the "Make Install" section of this document, you can safely delete them.
The make command can be run with several options. make, make install and make uninstall has already been described above.
make clean deletes all the binary files (object files) and the motion
binary generated by make. It also deletes temporary files and any jpg files
that motion has saved in the motion source directory.
make distclean
deletes the files: config.status, config.log, config.cache, Makefile, and motion.spec.
make
updateguide fetches a fresh new copy of this guide and place it in your
motion source directory. Note that the pictures are not downloaded.
make
dist performs make clean, make distclean and make updateguide in one single
operation.
If you are upgrading from motion 3.0.X or from an older version of 3.1.X you should note that many options have been removed from version 3.1.13 and forward and many new have arrived. You still have all the old features. The options have been changed for two reasons. New more flexible features and to simplify getting started with Motion.
You should also note these differences.
The table below shows the new options in the left column and the options they replaced in the right column. Realmotion has not been replaced.
New Options |
Obsolete Options |
text_left |
drawtext_user |
jpeg_filename |
oldlayout |
snapshot_interval |
snapshots |
|
realmotion |
despeckle |
- |
pre_capture |
- |
onffmpegclose |
- |
ffmpeg_timelapse (v. 3.1.14) | ffmpeg_timelaps (renamed v 3.1.14) |
ffmpeg_timelapse_mode |
- |
sql_log_image |
- |
minimum_motion_frames |
- |
You have the following sources of information:
This document (you are
lucky to have found it).
The author of the program has written a description
of the technology behind motion.
The man page. After installation simply
write man motion
The default motion.conf file that comes with the package.
Misc.
document that comes with the package gives a few hints. When this is written
the FAQ describes the wrong information about where motion searches for the
motion.conf file.
Input devices: Here we are thinking about the cameras.
Motion supports
video input from two kinds of sources.
Standard video4linux devices (e.g. /dev/video0). Motion has no drivers for
cameras. Installing the camera itself is outside the scope of this document.
But here are some nice links.
Network cameras (which are actually cameras with a built in web server that can be connected directory to your network).
Motion is invoked from the command line. It has no GUI. Everything is controlled from the command line and from config files. The editor recommend only using the config files as this is easier in the long run and much less confusing having all options in one place.
A few important definitions.
The name of the config file must be 'motion.conf'. When you invoke Motion it will search for the configuration file called 'motion.conf' in the following order:
If you have write access to /usr/local/etc then the editor recommends having only one motion.conf file in the default /usr/local/etc/ directory.
Motion has a configuration file in the distribution package called motion-dist.conf.
When you run 'make install' this files gets copied to the /usr/local/etc directory.
The
configuration file needs to be renamed from motion-dist.conf to motion.conf.
The original file is called motion-dist.conf so that your perfectly working
motion.conf file does not accidentally get overwritten when you re-install or
upgrade to a newer version of Motion.
If you have more than one camera you should not try and invoke Motion more
times. Motion is made to work with more than one camera in a very elegant way
and the way to do it is to create a number of thread config files. Motion will
then create an extra tread of itself for each camera. If you only have one camera
you only need the motion.conf file. The minute you have two or more cameras
you must have one thread config file per camera.
An option that is common to all cameras can be placed in motion.conf. (You
can also put all parameters in the thread files but that makes a lot of editing
when you change a common thing).
An option that is unique to a camera must be defined in each thread file.
The first camera is defined in the first thread
file called from motion.conf. The 2nd camera is defined in the 2nd thread file
called from motion.conf etc.
Any option defined in motion.conf will be used for all cameras except for the cameras in which the same option is defined in a thread config file.
Motion reads its configuration parameters in the following sequence. If the same parameter exists more than one place the last one read wins.
So always call the thread config files in the end of the motion.conf file. If you define options in motion.conf AFTER the thread file calls, the same options in the thread files will never be used. So always put the thread file call at the end of motion.conf.
If motion is built without specific features such as ffmpeg, mysql etc it will ignore the options that belongs to these features. You do not have to remove them or comment them out.
If you run the XML-RPC command motion.conf.write (motion-control conf write) motion will overwrite motion.conf and all the thread.conf files by autogenerated config files neatly formatted and only with the features included that Motion was built with. If you later re-build Motion with more features or upgrade to a new version, you can use your old config files, run the motion.conf.write command, and you will have new config files with the new options included all set to their default values. This makes upgrading very easy to do. It requires that Motion is built with the XML-RPC feature.
SYNOPSIS
motion [ -BCDhlmNpQw] [ -a seconds] [ -c changes] [ -d device]
[ -E command]
[ -F file] [ -f nr] [ -G seconds] [ -g seconds] [ -i input]
[ -L noise] [ -M address] [ -n norm]
[ -O command] [ -P device] [ -q quality] [ -S nr] [ -s widthxheight] [ -t target dir]
[ -u user:pass ]
[ -U webcam_path ] [ -V device]
Option |
Description |
Editors comment |
-a seconds |
time between two automated snapshots, valid range: 0 to thousands, default: 0 |
The default value of 0 means that the feature is disabled. |
-B |
Encode all jpg images to mpeg after a event using mpeg_encode |
An event is defined as a series of motion images taken within a short timeframe. E.g. a person walking through the room is an event that may have caused 10 single jpg images to be stored. This option make motion (using mpeg_encode) to merge the individual jpg images into a small mpeg "film" showing the event. |
-C |
Output changes count for every frame, usable for tuning |
This feature writes the detected number of changed
pixels (after noise filtering) to the console. Motions outputs the
numbers for all threads continuously for every frame read from the
video device. The output format is "changes: number_of_changes".
The number is an expression
of how many pixels that changed and how much. The higher a value,
the more motion This feature does not work
when in daemon mode! |
-c changes |
threshold for detecting a change, Valid range: 1 to thousands, default: 1500. |
Use the -C switch to experiment to find the right value. If you do not get small movement detected (see the mouse on the kitchen floor) lower the value. If motion detects too many birds or moving trees, increase the number. |
-D |
Daemonize |
This means that motion is started as background
process(es) and you return to the command prompt right away. |
-d device |
video4linux capture device, default: /dev/video0 |
The syntax for the value is /dev/devicename where device name in Linux is normally video0, video1, video2 etc. The actual device number is set by the device driver. See the documentation for this. If you have more than one device you need to define them in config files instead. |
-E command |
Execute 'command' when detecting motion. |
The command is executed at the beginning of the
event before the images are stored. |
-F file |
pgm image to use as a mask for filtering motion. This file must have the same size as you have set for the video4linux device. |
Full path of the PGM (portable gray map) mask
file. |
-f number |
Maximum number of frames per second. Valid range: 0 to limit of camera, default: none |
Maximum number of picture frames per second that motion
takes when detecting movement. Default
is none which means that it takes as many as possible. |
-G seconds |
Minimum gap between two shots in seconds. 0 to thousands, default: 0 |
It is the minimum time from an image is saved till an image is saved again. |
-g seconds |
minimum gap between events, Valid range: 1 to thousands, default 60 |
An event is defined as a series of motion images taken within a short timeframe. E.g. a person walking through the room is an event that may have caused 10 single jpg images to be stored. This option defines how long a pause between detected motions that is needed to be defined as a new event. |
-h |
Display an short text with all command line functions. |
Display a short 1 line help text for each command option. Motion terminates right after having shown the text. If Motion already runs it is no problem. You can invoke it with the -h option without any impact on the running processes. |
-i input |
input channel to use expressed as an integer number starting from 0. Valid range: depends on video capture card, default: 8 |
If you have a video capture card you can define the channel to tune to using this option. If you are using a USB device, network camera or a capture card without tuner you should set the value to the default 8. Many TV tuner cards have the input channels: TV Tuner = 0, Standard composite video = 1, S-VHS = 3. Other have TV=0, composite video 1= 1, composite video = 2, S-VHS = 3. |
-L noise |
Noise level, all changes smaller than this level will be considered noise. Valid range: 1 to 255, default: 32 |
This is different from the threshold parameter. This is changes at pixel level. The purpose is to eliminate the changes generated by electric noise in the camera. Especially in complete darkness you can see the noise as small grey dots that come randomly in the picture. This noise can create false motion detection. What this parameter means is that the intensity of a pixel must change more than +/- the noise threshold parameter to be counted. |
-l |
Do not locate and mark motion on output pictures |
The mark is in the form of a rectangle on the saved images so that you can easily see what it was that was moving in the picture. It is a matter of taste if you want this. |
-M address |
Send a mail to 'address' when detecting motion. |
Uses the standard UNIX 'mail' program which is part of the 'sendmail' package. |
-m |
Output 'motion' images |
Motion images shows the motion content of the pictures. This is good for tuning and testing but probably not very interesting for the general public. Default is not to store motion images. Motion pictures have an m at the end of the filename. |
-N |
Don't output normal images |
Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image as defined above. Default is that normal images are stored. This option turns the feature OFF. |
-n norm |
norm to use (pal/pal-nc/ntsc/secam), default: pal |
Only relevant for capture cards. This sets the video coding standard for the card. In most of western Europe PAL is used. In France and some eastern European countries SECAM is used. In the Americas and Japan NTSC is used. |
-O command |
Execute 'command' when an image is saved. The name of the image will be given as argument. |
The command can be a simple UNIX command, a bash script, a perl program, a real binary program, anything. The program is given the stored image filename as a parameter. |
-P device |
video4linux video loopback input for normal images. If a dash '-' is given as device, motion will try to use /proc/video/vloopback/vloopbacks to find a free pipe on its own. default: not set |
See the video4linux loopback
device web site for more information about video loopback |
-p |
Output ppm images instead of jpeg. This will reduce CPU load but disk I/O will increase a lot. |
|
-Q |
Don't sound the warning beep when detecting motion. (This doesn't change anything in daemon mode, there never is a beep there) |
|
-q quality |
JPEG image quality, Valid range: 0-100,default: 75. |
100 means hardly compressed. A small number means a much smaller file size but also a less nice quality image to look at. 50 is a good compromise for most. |
-S number |
Send a SMS to number using sms_client when detecting motion. |
Not a feature that has received much attention recently. If you live in GSM land you are probably better off using the email to SMS gateway that most GSM providers have using your mail client. For more information see the sms_client home page. |
-s widthxheight |
Picture size, Valid range: Camera dependent, default: 352x288 |
Motion actually set the size of the image coming from the video4linux device. The selected size must be supported by the device. For some device drivers like pwc (driver for Philips USB cameras) setting the size to a non-standard value makes the driver create an image of the nearest smaller size and create a gray band around the image to fit the size given by motion. Note that it is the driver and not motion that generates the gray band. Motion will try to detect motion in the entire image including the gray band. |
-t target-dir |
destination for snapshots |
This is the target directory for all snapshots, motion images and normal images. The default is the current working directory (current working directory of the terminal from which motion was started). You will normally always want to specify this parameter either as a command line option or in the config file. |
-U url|IP_addr |
Webcam path |
URL for a net camera. |
-u user:pass |
For password-protected network cameras, use this option for the HTTP 1.1 Basic authentication mechanism. default: No authentication |
Only relevant for network cameras. |
-V device |
Output device name |
Device name that motion uses to generate output. See the video4linux loopback device web site for more information about video loopback. Note: This is not the capturing device name. To set the capturing device use the -d option. |
-w |
Activate light switch filter. With this option on motion will not classify sudden light differences as a motion (not 100% fail proof!) |
Default (switch not set) is off. |
These are the options that can be used in the config file. They are
overridden by the command line!
All number values are integer numbers (no
decimals allowed). Boolean options can be on or off (values "1", "yes"
and "on" all means true and any other value means false).
Some configuration options are only used if Motion is built on a system that has the matching software libraries installed (cURL, MySQL, PostgreSQL and FFMPEG).
cURL (libcurl)
netcam_url, netcam_userpass
MySQL
mysql_db, mysql_host, mysql_user, mysql_password
PostgreSQL
pgsql_db, pgsql_host, pgsql_user, pgsql_password, pgsql_port
FFMPEG (libavcodec)
ffmpeg_cap_new, ffmpeg_cap_motion, ffmpeg_filename,
ffmpeg_timelapse, ffmpeg_timelapse_mode, ffmpeg_bps
All the options in alphabetical order.
Option |
Description |
Detailed Comment |
adjust_rate on|off |
Try to make the frame rate of the created mpegs as normal as possible. Normal means round 25 frames per second. Allowed values: on, off. Default: off |
Only used for the Berkeley mpeg_encode. It is
not used by ffmpeg. |
always_changes on|off |
Always display the differences between the captured frame and the reference frame. This can come in handy while tuning your setup. Default: off |
This feature writes the detected number of changed
pixels (after noise filtering) to the console. Motions outputs the
numbers for all threads continuously for every frame read from the
video device. The output format is "changes: number_of_changes".
The number is an expression
of how many pixels that changed and how much. The higher a value,
the more motion This feature does not work
when in daemon mode! |
auto_brightness on|off |
Motion will try to adjust the brightness of the video device if the images captured are to dark or to light. This option will be most useful for video devices like web cams, which sometimes don't have such an option in hardware. Default: off |
With this option enabled motion will try to regulate the brightness of a video device. If your video device already does this for you this option might cause oscillations. Editor recommends to experiment for best result. |
berkeley_single_directory on|off |
Use single directory structure (For Berkeley mpeg_encode
feature only) |
If this option is set to 'on' motion will use
a single directory structure (given by the option 'target_dir') for saving Berkeley
mpeg_encode mpegs with filenames in the format 'No-YYYYMMDDHHMMSS-Fm'.
No is the event number, Fm the frame number for that second. As
default motion will create directories for years, months, days and
so on in the target_dir. IMPORTANT IF YOU USE Berkeley mpeg_encode |
control_localhost on|off |
Limits the xml-rpc control to the localhost. Default: on |
By setting this to on, the control using xml-rpc can only be accessed on the same machine on which Motion is running. |
control_port port_no |
Sets the port number for the xml-rpc based remote control. Default: 0 (not defined) |
This sets the port number to be used for control of motion using xml-rpc. Port numbers below 1024 normally requires that you have root privileges. Port 8080 is a fine choice of port to use for the purpose. |
daemon on|off |
Start motion in daemon mode and release terminal. Default: off |
Daemon
mode is what you typically will use once you are done experimenting
and have motion run permanently in the background on a server. |
despeckle EedD (and other combinations of E, e, d and D). |
Despeckle motion image using (e)rode or (d)ilate. Default: Not defined = off. |
A way of tuning (by removing or enhancing) noise
in the motion image. Options are any of 'e', 'E', 'd' or 'D'. Default:
Not Defined (Don't despeckle). |
debug_parameter integer |
Debug parameter does not have any function. |
The debug parameter is available for software debugging. If you want to test and debug the source code this parameter can be set anywhere in the code and its value read using the xml-rpc remote control interface. This way you can read the value of a variable, or identify where in the code the program get stuck. Unless you play with the source code this option has no function. In the current version the option is not assigned anywhere in the code. |
execute command |
External command to be executed when detecting motion. Default: Not defined |
Do not write "none" if you do not want to execute commands. Simply do not include the option in the file or comment it out by placing a "#" as the first character on the line before the execute command. |
ffmpeg_bps bps |
Bitrate of mpegs produced by ffmpeg. Default:
400000 (400kbps). |
To use this feature you need to install the FFmpeg
Streaming Multimedia System. |
ffmpeg_cap_new on|off |
Use ffmpegs libavcodec to encode mpeg movies in
realtime. Default =
off. |
To use this feature you need to install the FFmpeg
Streaming Multimedia System |
ffmpeg_cap_motion on|off |
Use ffmpegs libavcodec to encode motion type mpeg movies in
realtime. Default =
off. |
To use this feature you need to install the FFmpeg
Streaming Multimedia System |
ffmpeg_filename value |
File path for motion triggered ffmpeg films (mpeg) relative to target_dir. Default: %v-%Y%m%d%H%M%S |
Default value is equivalent to legacy 'oldlayout'
option |
ffmpeg_timelapse_mode |
The file rollover mode of the timelapse video. |
Note that it is important that you use the conversion specifiers in ffmpeg_filename that ensure that the new timelapse file indeed is a new file. If the filename does not change Motion will simply append the timelapse pictures to the existing file. Manual means that Motion does not automatically rollover to a new filename. You can do it manually using XML-RPC by setting the option 'ffmpeg_timelapse' to 0 and then back to your chosen value. Hourly rolls over on the full hour. Value 'daily' which is the default rolls over at midnight. There are two weekly options because depending on where you come from a week may either start on Sunday or Monday. And 'monthly' naturally rolls over on the 1st of the month. |
ffmpeg_timelapse seconds |
Use ffmpegs libavcodec to encode a timelapse movie. saving a picture frame at the interval in seconds set by this parameter. Default = 0. Set it to 0 if not used. |
To use this feature you need to install the FFmpeg
Streaming Multimedia System. |
framerate number |
Maximum number of frames that are saved per second.
Valid range: 2-100. Default: 100 (almost no limit). |
Note. Motion will stop storing pictures if the
framerate is set to less than 2. |
frequency value |
The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it) |
This option is on relevant if you have a TV tuner card where you can select the tuner frequency. Your tuner card must support this feature. |
gap seconds |
The minimum gap between two events in seconds. Default: 60 |
An event is defined as a series of motion images taken within a short timeframe. E.g. a person walking through the room is an event that may have caused 10 single jpg images to be stored. This option defines how long a pause between detected motions that is needed to be defined as a new event. |
height pixels |
The height of each frame. Valid range: Camera dependent, default: 288 |
The height of the image in pixels. Motion does
not scale so should be set to the actual size of the v4l device.
In case of a net camera motion sets the height to the height of
the first image read. |
input number |
input channel to use expressed as an integer number starting from 0. Valid range: depends on video capture card, default: 8 |
This parameter is really used only with video capture
cards that has more than one input. |
jpg_cleanup on|off |
Remove all jpeg images after making a mpeg movie of them. Default: off |
Only used for the Berkeley mpeg_encode. |
jpeg_filename value |
File path for motion triggered images (jpeg or ppm) relative to target_dir (Default: %v-%Y%m%d%H%M%S-%q) |
Default value is equivalent to legacy 'oldlayout'
option IMPORTANT IF YOU USE Berkeley mpeg_encode |
lightswitch on|off |
Activate light switch filter. With this option on motion will not classify sudden light differences as a motion (not 100% fail proof!). Default: off |
Editors recommendation. Experiment to see what works best for your application. |
locate on|off |
Locate and draw a box around the moving object. Default: off |
|
low_cpu framerate |
When this option is not zero motion will be in a low cpu mode while not detecting motion. In low cpu mode Motion reduces the framerate to the value given for this option. Value zero means disabled. Default: 0 (disabled). |
This is smart for running a server that also does other tasks such as running Apache, MySQL etc. Motion grabs this lower number of frames per second until it detects motion. Then it speeds up to normal speed and take pictures as set by the option "framerate". |
mail address |
Address to send an e-mail to when detecting motion Default: Not defined |
Address in the normal form name@domain.name. An e-mail is sent for each event. Not each picture. |
mask_file file |
PGM file to use as a sensitivity mask. This picture MUST have the same width and height as the frames being captured and be in binary format. Default: Not defined. |
Full path of the PGM (portable gray map) mask
file (binary format). |
max_mpeg_time seconds |
The maximum length of an mpeg movie. Default: 3600 seconds (one hour). Set this to zero for unlimited length. |
|
mpeg_encode on|off |
Use the Berkeley mpeg encoder 'mpeg_encode' to make movies of the events. Default: off |
For more information here is a link to the Berkeley
mpeg encoder. IMPORTANT IF YOU USE Berkeley mpeg_encode |
mpeg_encode_bin path |
Specify the path to the mpeg_encoder. Default is /usr/local/bin/mpeg_encode |
This option is not included in the default motion.conf file. It specifies the path to the Berkeley mpeg_encode executable binary file. The default value is /usr/local/bin/mpeg_encode. This is normally where the encoder gets installed if you build from source. But if you install a binary RPM the encoder will most likely end up in /usr/bin/mpeg_encode. In this case set this option. |
minimum_gap seconds |
The minimum time between two shots in seconds. Valid range: 0 to thousands, default: 0 (no minimum) |
This is the minimum gap between the storing pictures while detecting motion. The value zero means that pictures can be stored almost at the framerate of the camera. |
minimum_motion_frames number |
Picture frames must contain motion at least the specified number of frames in a row before they are detected as true motion. At the default of 1, all motion is detected. Valid range: 1 to thousands, recommended 1-10. |
Note that the picture frames are buffered by Motion and once motion is detected also the first frames containing motion are saved so you will not miss anything. The feature is used when you get many false detections when the camera changes light sensitivity or light changes. Experiment for best setting. Valid range is 0 to 1000s but for each step larger than 1 Motion reserves space in RAM for the picture frame buffer. Practical range is 1 to 10. |
motion_video_pipe devicename|- |
The video4linux video loopback input device for motion images. If a particular pipe is to be used then use the device filename of this pipe, if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set |
Using this you can view the results in real time.
E.g. by using the program camstream.
The
difference between this option and the video-pipe option is that
this option shows the motion version of the images instead of the
normal images. |
mysql_db |
Name of the MySQL database. Default: Undefined |
MySQL CONFIG FILE OPTION. Motion must be built
with MySQL libraries to use this feature. |
mysql_host |
IP address or domain name for the MySQL server. Use "localhost" if motion and MySQL runs on the same server. Default: Undefined. |
MySQL CONFIG FILE OPTION. Motion must be built with MySQL libraries to use this feature. |
mysql_user |
The MySQL user name. Default: Undefined |
MySQL CONFIG FILE OPTION. Motion must be built with MySQL libraries to use this feature. |
mysql_password |
The MySQL password. |
MySQL CONFIG FILE OPTION. Motion must be built with MySQL libraries to use this feature. |
netcam_url URL |
Specify an url to a downloadable jpeg file to
use as input device. Such as an AXIS 2100 network camera. Default:
not set. |
Example of URL: http://www.gate.com/pe1rxq/jeroen.jpg. |
netcam_userpass user:pass |
For network cameras protected by username and
password, use this option for HTTP 1.1 Basic authentication. The
string is specified as username:password. Default: No authentication |
Important
note: To use the Netcam options you must have the cURL shared library
"libcurl" installed on your system. |
night_compensate on|off |
When this option is set the noise threshold will be lowered if the picture is dark. This will improve the sensitivity in dark places. However it might also increase the number of false alarms since most cameras also compensate for this with their AGC which will increase noise. Default: off |
Editors recommends to experiment for best result as this depends heavily on the camera and light conditions. Do not use this with 'noise_tune' on. |
noise_level level |
The noise level is used as a threshold for distinguishing between noise and motion. Valid range: 1 to 255, default: 32 |
This is different from the threshold parameter. This is changes at pixel level. The purpose is to eliminate the changes generated by electric noise in the camera. Especially in complete darkness you can see the noise as small grey dots that come randomly in the picture. This noise can create false motion detection. What this parameter means is that the intensity of a pixel must change more than +/- the noise threshold parameter to be counted. |
noise_tune on|off |
Activates the automatic tuning of noise level. Default: on. |
This feature makes Motion continuously adjust the noise threshold for distinguishing between noise and motion. The 'noise_level' setting is ignored when activating this feature. This is a new feature and new algorithm. It may give different results depending on camera and light conditions. Report your experience with it on the Motion mailing list. If it does not work well, deactivate the 'noise_tune' option and use the manual setting of 'noise_level' instead. |
norm 0|1|2|3 |
Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL) |
This value is only used for capture cards using the BTTV driver. |
onffmpegclose command |
Execute 'command' when an ffmpeg movie is closed at the end of an event. The name of the movie will be given as argument. Default: not set. |
Full path name of the program/script. |
onmpeg command |
Execute 'command' when an mpeg movie is generated. The name of the movie will be given as argument. Default: not set. |
Full path name of the program/script. |
onsave command |
Execute 'command' when an image is saved. The name of the image will be given as argument. Default: not set. |
Full path name of the program/script. |
output_all on|off |
Picture are saved continuously as if motion was detected all the time. |
This feature is not meant to be the normal mode
of operation. Especially not if you have the output_normal or output_motion
features enabled since it will keep on saving pictures on the disk
and you will soon run out
of disk space. So be careful with this command.. If your frame rate is 10 pictures per
second motion will save 10 new picture pr second until the disk
is full. All features are triggered like it was a detection of motion
incl mpeg generation and running the program given by onsave. This
parameter is default off. |
output_motion on|off |
Output pictures with only the moving object. Default: off |
Motion images shows the motion content of the
pictures. This is good for tuning and testing but probably not very
interesting for the general public. Default is not to store motion
images. Motion pictures are stored the same place and with the same
filename as normal motion triggered pictures except they have an "m" appended
at the end of the
filename before the .jpg or .ppm. E.g. the name can be 01-20020424232936-00m.jpg. |
output_normal on|off |
Output 'normal' pictures. Default: on |
Normal image is an image that is stored when motion is detected. It is the same image that was taken by the camera. I.e. not a motion image as defined above. Default is that normal images are stored. |
pgsql_db |
Name of the PostgreSQL database. Default: undefined |
PostgreSQL CONFIG FILE OPTION. Motion must be
built with PostgreSQL libraries to use this feature. |
pgsql_host |
IP address or domain name for the PostgreSQL server. Use "localhost" if motion and PostgreSQL runs on the same server. Default: undefined |
PostgreSQL CONFIG FILE OPTION. Motion must be built with pgsql_db libraries to use this feature. |
pgsql_user |
The PostgreSQL user name. Default: undefined |
PostgreSQL CONFIG FILE OPTION. Motion must be built with PostgreSQL libraries to use this feature. |
pgsql_password |
The PostgreSQL password. Default: undefined |
PostgreSQL CONFIG FILE OPTION. Motion must be built with PostgreSQL libraries to use this feature. |
pgsql_port |
The PostgreSQL server port number. Default is 5432 |
PostgreSQL CONFIG FILE OPTION. Motion must be built with PostgreSQL libraries to use this feature. |
post_capture number |
Specifies the number of frames to be captured after motion has been detected. Valid range: 0 to thousands, default=0. |
The purpose of this is mainly to create smooth video clips each time motion is detected. Use it to you personal taste (and disk space).. |
ppm on|off |
Output ppm images instead of jpeg. This uses less CPU time, but causes a LOT of hard disk I/O, it is generally slower than jpeg. Default: off |
Editors recommendation is to always use jpg except if you have a specific need to store high quality pictures without any quality loss. For web cameras you should always choose jpg. Note that the built in webcam server requires that this parameter is set to off. |
pre_capture number |
Specifies the number of previous frames to be outputted at motion detection. Valid range: 0 to thousands, default=0. |
Motion buffers the number of picture frames defined by 'pre_capture'. When motion is detected the pictures in the buffer are included in the video clip generated by ffmpeg. The effect is that it seems the program knew in advance that the event was going to take place and started the recording before it actually happened. This is a nice feature that give more complete video clips of an event. The recommended value would be approx 0.5-1 second of video so the value should be defined so it fit the framerate and the desired pre-capture time. E.g. 0.5 second at 20 frames pr second would mean a value of 10. |
predict_description filename.desc |
Load prediction description file. This option can be repeated for each additional files that needs to be loaded. |
When the predict_enable feature is enabled, Motion saves a file ending with .desc in the target directory. These files can merged into prediction description files that contains a number of detected motions put into number codes. Using the predict_description option a multiple number of times Motion will load in these description files and will now be able report the name of the prediction motion to the console. The idea is that later features will be added that can take specific actions when it recognize special motion patterns. This feature is still very new and very experimental. Consider it fun and games for now. Report any interesting experience on the Motion mailing list. |
predict_enable on|off |
Enable the new experimental prediction feature. Default: off. |
The prediction feature is very new and very experimental. It is a way for Motion to recognize motions patterns stored in prediction files and take actions accordingly. At the moment all Motion can do is report recognition as a "Best Guess: Prediction_name value" on the console. Ie. it cannot do anything in Daemon mode. |
predict_filename value |
File path for prediction files. Default: %v-%Y%m%d%H%M%S |
Default value is equivalent to legacy 'oldlayout'
option |
predict_threshold value |
Set threshold for reporting motion as predicted on the console. Default: 90 |
This parameter is only used to decide when to report a "Best guess" on the console. |
quality value |
The quality for the jpeg images. Valid range: 1-100,default: 75 |
100 means hardly compressed. A small number means a much smaller file size but also a less nice quality image to look at. 50 is a good compromise for most. |
quiet on|off |
Be quiet, don't output beeps when detecting motion. Default: off |
Only works in non-daemon mode. |
roundrobin_frames number |
Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) is possible. Default: 1 |
Round robin feature is described in a section later in this document. |
roundrobin_skip number |
Specifies the number of frames to skip after a switch. (1 of you are feeling lucky, 2 if you want to be safe). Default: 1 |
Round robin feature is described in a section later in this document |
sms number |
Number to send an SMS to with sms_client. Default: none |
Not a feature that has received much attention recently. If you live in GSM land you are probably better off using the e-mail to SMS gateway that most GSM providers have using your mail client. For more information see the sms_client home page. |
snapshot_filename value |
File path for snapshots (jpeg or ppm) relative to target_dir (Default: %v-%Y%m%d%H%M%S-snapshot) |
Default value is equivalent to legacy 'oldlayout'
option |
snapshot_interval seconds |
Make automated snapshots every N seconds. Valid range: 0 to thousands, default: 0 (No snapshots) |
The snapshots are stored in the target directory
+ the directory/filename specified by the 'snapshot_filename' option. |
sql_log_image on|off |
Log to the database when creating motion triggered image file (default: on). |
Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. |
sql_log_snapshot on|off |
Log to the database when creating a snapshot image file (default: on). |
Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. |
sql_log_mpeg on|off |
Log to the database when creating motion triggered mpeg file (default: off). |
Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. |
sql_log_timelapse on|off |
Log to the database when creating timelapse mpeg file (default: off). |
Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. |
sql_log_prediction on|off |
Log to the database when creating a prediction file (default: off). |
Configuration option common to MySQL and PostgreSQL. Motion must be built with MySQL or PostgreSQL support to use this feature. |
switchfilter on|off |
Turns the switch filter on or off. The filter can distinguish between most switching noise and real motion. With this you can even set roundrobin_skip to 1 without generating much false detection. Default: off. |
This is a round robin related feature used when you have a capture card with multiple inputs (controlled by the 'input' option) on the same videodevice. |
target_dir directory_path |
Target directory for pictures. Default: current working directory |
This is the target directory for all snapshots,
motion images and normal images. The default is the current working
directory (current working directory of the terminal from which
motion was started). You will normally always want to specify this
parameter either as a command line option or in the config file.
Use an absolute directory path (not relative) if you want to use
mpeg_encode. |
text_changes on|off |
Turns the text showing changed pixels on/off. Default: off |
By setting this option to 'on' the number of pixels that changed compared to the reference frame is displayed in the upper right corner of the pictures. This is good for calibration and test. Maybe not so interesting for a greater public. Set it to your personal taste. |
text_left TEXT |
User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ \n and conversion specifiers (codes starting by a %). Default: none |
User defined text is displayed in the lower left
corner of the pictures. If the option is not defined no text is
displayed at this position. The user defined text can be the english
alphabet and a selection of symbols: (A-Z,
a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ \n) and conversion
specifiers. You can place the text in quotation marks to allow
leading spaces. With a combination is spaces and newlines you can
position the text anywhere on the picture. |
text_right TEXT |
User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ \n and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock |
User defined text is displayed in the lower right
corner of the pictures. If the option is not defined no text is
displayed at this position. The user defined text can be the english
alphabet and a selection of symbols: (A-Z,
a-z, 0-9, " / ( ) @ ~ # < > | , . : - + _ \n) and conversion
specifiers. You can place the text in quotation marks to allow
leading spaces. With a combination is spaces and newlines you can
position the text anywhere on the picture. |
thread filename |
Thread option. With this a separate config file can be specified to be used for a new separate thread. |
This is used when you have more than more camera/device. |
threshold value |
Threshold for declaring motion. Valid range: 1 to thousands. Default: 1500. |
Use the -C command line option or the always_changes config file option to experiment to find the right threshold value. If you do not get small movement detected (see the mouse on the kitchen floor) lower the value. If motion detects too many birds or moving trees, increase the number. Practical values would be from a few hundred to 2000 indoors and 1000-10000 outdoors. |
threshold_tune on|off |
Activates the automatic tuning of threshold level. Default: on |
This feature makes Motion continuously adjust the threshold for declaring motion. The 'threshold' setting is ignored when activating this feature. This is a new feature and new algorithm. It may give different results depending on your camera, light conditions, indoor/outdoor, the motion to be detected etc. Report your experience with it on the Motion mailing list. If it does not work well, deactivate the 'threshold_tune' option and use the manual setting of 'threshold' instead. |
timelapse_filename value |
File path for timelapse mpegs relative to target_dir (ffmpeg only). Default: %v-%Y%m%d-timelapse |
Default value is equivalent to legacy 'oldlayout'
option |
track_type number |
Type of tracker (0=none, 1=stepper, 2=iomojo, 3=pwc). Default: 0. |
Motion has special
tracking options which use either a serial stepper motor controller,
an iomojo smile cam or a Philips WebCam driver compatible pan/tilt
camera such as the Logitech Quickcam Sphere or Orbit. |
track_iomojo_id |
Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller. Default: 0 |
Only used for iomojo camera |
track_maxx |
The maximum position for servo x. Default: 0 |
Only used for stepper motor tracking. |
track_motorx |
The motor number that is used for controlling the x-axis. Default: -1 |
Only used for stepper motor tracking. |
track_port |
This is the serial port to which the stepper motor interface is connected. Default: Not defined |
Only used for stepper motor tracking. |
track_speed |
Speed to set the motor to. Default: 255 |
Only used for stepper motor tracking. |
track_stepsize |
Number of steps to make. Default: 40 |
Only used for stepper motor tracking. |
videodevice device_name |
The videodevice to be used for capturing. Default: /dev/video0 |
This is the video4linux device name. |
video_pipe device_name|- |
The video4linux video loopback input device for normal images. If a particular pipe is to be used then use the device filename of this pipe, if a dash '-' is given motion will use /proc/video/vloopback/vloopbacks to locate a free pipe. Default: not set |
Using this you can view the results in real time.
E.g. by using the program camstream.. The
difference between this option and the video-pipe option is that
this option shows the normal version of the images instead of the
motion images. |
webcam_limit on|off |
Limit the number of frames to number frames. After nr frames the connection will be closed by motion. Default: 0 |
Number can be defined by multiplying actual webcam rate by desired number of seconds. Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate. |
webcam_localhost on|off |
Limits the access to the webcam to the localhost. Default: on |
By setting this to on, the webcam can only be accessed on the same machine on which Motion is running. |
webcam_maxrate rate |
Limit the framerate of the webcam. Default is 100. |
Webcam feature is described in a section later in this document |
webcam_motion on|off |
If set to 'on' Motion only sends pictures to the client when motion is detected. When 'off' Motion sends frames continuously. Default is off. |
Webcam feature is described in a section later in this document |
webcam_port port_no |
TCP port on which motion will listen for incoming connects with its http server. Default is 0 which is disabled. |
Webcam feature is described in a section later in this document |
webcam_quality level |
Quality setting for the jpeg files transferred over this connection (usually very low). Default is 30. |
Webcam feature is described in a section later in this document |
width pixels |
The width of each frame. Valid range: Camera dependent, default: 352 |
Motion does not scale so should be set to the
actual size of the v4l device. In case of a net camera motion sets
the height to the height of the first image read. |
A signal can be sent from the command line by typing e.g. kill -s SIGHUP
pid, where the last parameter is the process ID which you get by typing
ps -ef | grep motion. The PID is the first on the list which is the parent
process for the threads.
Motion responds to the following signals:
Signal |
Description |
Editors comment |
SIGALRM |
Motion will generate a snapshot. |
|
SIGHUP |
The config file will be reread. |
This is a very useful signal when you experiment with settings in the config file. |
SIGTERM |
If needed motion will create an mpeg file of the last event and exit |
|
SIGUSR1 |
Motion will create an mpeg file of the current event. |
|
Before you can start using motion you need to know some basics about your
camera.
Either you have a camera connected directly to your computer. In
this case it is a video4linux type of camera. Or you connect to a network camera
using a normal web URL.
You need to install your camera with the right driver. It is out of scope of this document to tell you how to do this and it depends on which type of camera. Once installed the camera(s) will have the device names /dev/video0, /dev/video1, /dev/video2...
Your camera or capture/TV card will not support any picture size. You must know which frame size (width and height) the camera supports. If you do not know start with width 320 and height 240 which most cameras and capture cards supports.
You also need to choose framerate. The faster you fetch picture from the camera the more CPU load you get and the more pictures get included when Motion is detected. The value must be minimum 2.
You need to know if the camera supports auto brightness. Most cameras have auto everything. If you do not know assume that it has and do not use the Motion autobrightness feature. At least not to start with.
USB cameras take a lot of bandwidth. A USB camera connected to a USB 1.1 port or hub consumes all the bandwidth. Even with a small framesize and low framerate you should not expect to have more than one camera per USB 1.1 controller. If you need more than 1 USB camera add extra USB PCI cards to your computer. There exists cards that have 4 inputs each with their own controller and with full bandwidth. Must 4-input cards only have 1 controller. USB cameras do not have the feature of selecting input channels. To disable the input selection the option 'input' must be set to the value 8 for USB cameras (default).
Composite video cards are normally made with a chip called BT878 (older cards
have a BT848). They all use the Linux driver called 'bttv'.
There are cards
with more then one video input but still only one BT878 chip. They have a video
multiplexer which input is selected with the config option 'input'. Input channel
numbers start at 0 (which is why the value 8 and not 0 disables input selection).
There are video capture cards available with 4 or 8 inputs but only one chip.
They present themselves as one single video device and you select input using
the 'input' option. If you define e.g. 4 thread config files with the same videodevice
name but different input numbers Motion automatically goes into round robin
mode. See the round robin section for more information. Many TV tuner cards
have the input channels: TV Tuner = 0, Standard composite video = 1, S-VHS = 3.
Other have TV=0, composite video 1= 1, composite video = 2, S-VHS = 3. For
video capture cards input 1 is normally the composite video input.
Some capture cards are specially
made for surveillance with for example 4 inputs. Others have a TV tuner, a composite
input (phono socket) and perhaps also a S-VHS input. For all these cards the
inputs are numbered. The numbering varies from card to card so the easiest is
to experiment for 5 minutes with a program that can show the videostream. Use a program such as Camstream or xawtv to experiment with the values.
If
you use the TV tuner input you also need to set the frequency of the TV channel
using the option 'frequency'. Otherwise set 'frequency' to 0.
Finally you
need to set the TV norm. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default
is 0 (PAL).
If your camera is a PAL black and white you may get a better result with norm=3
(PAL no colour).
If the netcam_url option is defined all the video4linux options are ignored so make sure the netcam_url option is commented out if you do not need it.
These are the parameters used for video4linux devices.
########################################################### # Capture device options ############################################################ #Videodevice to be used for capturing (default /dev/video0) videodevice /dev/video0 #The video input to be used (default: 8) #Should normally be set to 1 for video/TV cards, and 8 for USB cameras input 1 #The video norm to use (only for video capture and TV tuner cards) #Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL) norm 0 #The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0) frequency 0 #Image width (pixels). Valid range: Camera dependent, default: 352 width 320 #Image height (pixels). Valid range: Camera dependent, default: 288 height 240 #Maximum number of frames to be captured per second. #Valid range: 2-100. Default: 100 (almost no limit). framerate 2 #Let motion regulate the brightness of a video device (default: off) #Only recommended for cameras without auto brightness auto_brightness off
Motion can connect to a network camera through a normal TCP socket. All you
need to give it is the URL. The URL given must return one single jpeg picture.
For the time being Motion cannot connect to a video stream such a mpeg, mpeg4,
divx or mjpeg. The URL must return one single jpeg image!
Also watch out
that you do not use a URL that create an HTML page with an embedded jpg. What
must be returned is the jpg picture itself.
When the netcam_url is defined all the video4linux options above are ignored!!
#URL to use if you are using a network camera, size will be autodetected (incl http://) #Must be a URL that returns single jpeg pictures. Default: Not defined ; netcam_url value #Username and password for network camera (only if required). Default: not defined #Syntax is user:password ; netcam_userpass value
This feature is automatically activated where multiple threads are sharing
the same video device. Each thread can then set different input channels or
frequencies to change camera. These are the special Round Robin options:
-
If multiple threads use the same video device, they each can capture roundrobin_frames
number of frames before having to share the device with the other threads.
-
When another thread wants to watch another input or frequency or size the first
roundrobin_skip number of frames are skipped to allow the device to
settle.
- The last option switch_filter is supposed to prevent the
change of camera from being detected as Motion. Unfortunately it seems that
many have problems detecting motion at all when this option is enabled. We are
working on improving it. You are probably better off turning this option off.
Note that in version 3.0.7 the two options are spelled roundrobing_frames
and roundrobing_skip. From version 3.1.8 the spelling has been corrected to roundrobin_frames
and roundrobin_skip. If you upgrade from 3.1.6 or earlier, remember to update
your config files to the right spelling for these two features.
These are the options that controls the detection of motion. Further details follows after.
############################################################ # Motion Detection Settings: ############################################################ #Threshold for number of changed pixels in an image that #triggers motion detection (default: 1500) threshold 2000 #Automatically tune the threshold down if possible (default: on) threshold_tune off #Noise threshold for the motion detection (default: 32) noise_level 32 #Automatically tune the noise threshold (default: on) noise_tune off #Enables motion to adjust its detection/noise level for very dark frames #don't mix with noise_tune (default: off) night_compensate on #Despeckle motion image using (e)rode or (d)ilate (Default: not defined) #Recommended value is EedD. Any combination (and number of) of E, e, d, and D is valid. #Comment out to disable despeckle EedD #PGM file to use as a sensitivity mask. #Full path name to. (Default: not defined) ; mask_file value #Try to filter out sudden light switches (default: off) lightswitch on #Picture frames must contain motion at least the specified number of frames #in a row before they are detected as true motion. At the default of 1, all #motion is detected. Valid range: 1 to thousands, recommended 1-10 minimum_motion_frames 1 #Specifies the number of pre-captured (buffered) pictures from before motion #was detected that will be output at motion detection (default: 0) pre_capture 2 #Number of frames to capture after motion is no longer detected (default: 0) post_capture 0 #Minimum gap between two events (seconds) (default: 60) #An event is defined as a series of motion images taken within a short timeframe. gap 60 #Minimum gap in seconds between the storing pictures while detecting motion. #Default: 0 = as fast as possible (given by the camera framerate) minimum_gap 0 #Maximum length in seconds of an mpeg movie (common for ffmpeg and Berkeley types) #When value is exceeded a new mpeg file is created. (Default: 0 = infinite) max_mpeg_time 0 #Number of frames per second to capture when not detecting #motion (saves CPU load) (Default: 0 = disabled) low_cpu 0 #Always save images even if there was no motion (default: off) output_all off
The 'threshold' option is the most important option. When motion runs it compares the current image frame with the previous and counts the number of changed pixes (ignoring the ones that have changes intensity less then defined by 'noise_level'). If more pixels then defined by 'threshold' have changed we assume that we have detected motion. Set the threshold as low as possible so that you get the motion you want detected but large enough so that you do not get detections from noise and plants moving. Note that the larger the your frames are, the more pixels you have. So for large picture frame sizes you need a higher threshold.
Any camera produces noise. This can especially be seen in the dark. To avoid that noise triggers motion, each pixel must change intensity over a certain limit before it is counted. This limit is defined by the option 'noise_level'.
Automatic threshold tuning and
automatic noise tuning can be activated or deactivated by the config
file options 'threshold_tune' and 'noise_tune'.
Both algorithms are still
new and
may not yet be optimal. Try them and if they do not work, use the good old manual
setting. We on the Motion mailing list are always interested in hearing your
experience and especially any improvement you may have made to the source.
The option 'night compensate' allows the noise threshold to be lowered if the picture is dark. This will improve the sensitivity in dark places. However it might also increase the number of false alarms since most cameras also compensate for this with their AGC which will increase noise. Default: off. Do not use this with 'noise_tune' on.
A way of tuning (by removing or enhancing) noise in the motion
image. Options are any of 'e', 'E', 'd' or 'D'. Default: Not defined (don't
despeckle).
Wind blowing grass and trees around or poor light conditions can
cause a lot of dots (or noise) to appear in the motion image (See the section on
Tuning Motion). This feature removes (or enhances!) this noise and so improves
the reliability of motion.
The 'e' option removes diamonds, 'E' removes
squares and alternating eE will remove circles. Each e/E you add will shrink the
noise by a pixel all the way around. So 'despeckle Ee' will remove circles of
radius 2. However, this will also shrink the detection by 2 and will affect the
threshold. So to remove noise and then restore the detected motion to its
original size try 'despeckle EedD'.
The value EedD is a good starting point.
The possible combinations are endless and it requires many experiments to find
the best combination. If you have very few problems with false detections leave
this option either blank or at EedD which will remove most of the single pixel
noise.
A very detailed technical explanation can be found at the webpage of
the author of this feature Ian
McConnell's Webcam: Motion Web Page
The mask file must be a pgm format image file (portable gray map). Note that you must
choose the BINARY format.
The feature is simple. Create an image of exact
the same size as the ones you get from your video device (camera). Make a purely
white picture and paint the areas that you want to mask out black. You can also
make gray areas where you want to lower the sensitivity to motion. Normally
you will stick to pure black and white.
One easy method for generating the
mask file is as follows.
You can just take a motion captured picture, edit
it with black and white for the mask and save it as a pgm file.
If you cannot
save in this format save as a grayscale jpg and then you can convert it to pgm
format with
djpeg -grayscale -pnm [inputfile] > mask.pgm
(assuming you have djpeg installed - part of the jpeg lib package).
Note that the mask file option masks off the detection of motion. The entire picture is still shown on the picture. This means that you cannot use the feature to mask off an area that you do not want people to see.
Below are an example of a webcam picture and a mask file to prevent the detection cars in the street.
Normal picture. Notice the street is visible through the hedge.
Mask file (converted to png format so it can be shown by your web browser)
With 'lightswitch' on motion will not classify sudden light differences as a motion (not 100% fail proof!). Default: off. In practical this does not work very well.
Picture frames must contain motion at least the specified number of frames
in a row before they are detected as true motion.
At the default of 1, all
motion is detected. Valid range: 1 to thousands, recommended 1-10.
Note that the picture frames are buffered by Motion and once motion is detected also the first frames containing motion are saved so you will not miss anything.
The feature is used when you get many false detections when the camera changes light sensitivity or light changes.
Experiment for best setting. Valid range is 0 to 1000s but for each step larger than 1 Motion reserves space in RAM for the picture frame buffer. Practical range is 1 to 10.
Motion buffers the number of picture frames defined by the config option 'pre_capture'. When motion is detected an ffmpeg generated film will begin with the buffered picture frames followed by the frames that were detected as motion and finally additional picture frames are added given by the config option 'post_capture'. The buffered pictures will also be saved as motion triggered images.
The result is that when you see the mpeg films generated by ffmpeg, it appears Motion was able to predict the future and start the film capturing before the event actually started.
If pre_capture is set to 0 the feature is disabled. You can have up to 1000s of pre-captured frames but naturally this makes motion leave a larger footprint in the memory of the computer.
The option 'post_capture' specifies the number of frames to be captured after motion has been detected. Valid range: 0 to thousands, default=0. The purpose of this is mainly to create smooth video clips each time motion is detected. Use it to you personal taste (and disk space).
The option 'gap' is important. It defines how long a period of no motion detected it takes before we say an event is over. An event is defined as a series of motion images taken within a short timeframe. E.g. a person walking through the room is an event that may have caused 10 single jpg images to be stored. This option defines how long a pause between detected motions that is needed to be defined as a new event. A good starting value is 60 seconds.
This option has nothing to do with the 'gap' option. This is the minimum gap between the storing pictures while detecting motion. The value zero means that pictures can be stored almost at the framerate of the camera. Normally you will set this to 0.
The option max_mpeg_time defines the maximum length of an mpeg movie. Default: 3600 seconds (one hour). Set this to zero for unlimited length.
To save computer power on slow computers there is a 'low_cpu' option which lowers the number of frames per second that motion captures from the camera to the value defined by this option, when motion is not detected. A value of zero means that the low_cpu option is disabled.
This new feature is not meant to be the normal mode of operation.
Especially not if you have the output_normal or output_motion features enabled
since it will keep on saving pictures on the disk and you will soon run out
of disk space. All features are triggered like it was detecting
motion all the time. It does all the normal actions that are done when motion
is detected. It saves pictures on the harddisk, runs scripts, sends emails etc
as fast as the frame rate of the camera. So it is probably a good idea to run
with a low framerate when using this feature and to not use activate all the
features that saves files on the disk. This
parameter is default off and not included in the default motion.conf
file that comes with 3.1.10.
The idea of this feature is that
you can turn the feature on and off for a short period of time to test or to
generate continuous mpeg films when needed. You can then use the motion-control
program to turn the feature on a off.
The following options controls how Motion generates images when detection motion.
############################################################ # Image File Output ############################################################ #Output 'normal' pictures when motion is detected (default: on) output_normal on #Output pictures with only the pixels moving object (green ghost images) (default: off) output_motion off #The quality (in percent) to be used by the jpeg compression (default: 75) quality 75 #Output ppm images instead of jpeg (default: off) ppm off
The 'option_normal' option activate saving normal pictures when detecting motion.
The 'output_motion' option activate saving pictures that shows which pixels have been detected as motion. You will normally set this option to 'off'. See the 'Tuning Motion' section.
The 'quality' option sets the quality (in percent) of the saved jpeg images. The higher the number the batter quality and the larger file sizes. A good compromise is 75%.
The option 'ppm' produces non compressed pictures in the ppm format. They take a lot of diskspace. Only recommended if you need a very high picture quality. This parameter must be 'off' if you wish to use the Berkeley mpeg_encode feature to make mpegs.
Motion contains a number of features that helps you tune the settings of
motion to the optimal. They are all described in the config file table above
but this section will try to illustrate them a bit more and give some guides
to how to tune.
The settings that are difficult to set are the settings that
decides or influence when to detect motion. These are
Special tuning options
Normal picture frame
Motion type picture frame without despeckle
Motion type picture frame with despeckle set to EedD
The ffmpeg option can generate mpeg films very fast and "on the fly".
This means that the mpeg film is growing each time motion is detected. With
the Berkeley mpeg_encode feature the film is generated based on the saved jpg
pictures. With ffmpeg the film is generated directly by motion.
Some people on the Motion mailing
list have had trouble building the ffmpeg package because they did not have
the NASM assembler package installed. So pay attention to this if you run into
problems.
Motion works with the current version 0.4.8 of ffmpeg which is the time of this document is the latest released version available at the ffmpeg website.
To build it from source follow these steps:
Download the ffmpeg and untar it to /usr/local/ffmpeg. Then it should
be a simple matter of entering the ffmpeg directory and run the commands
cd /usr/local/ffmpeg
./configure --enable-shared
make
make install
This creates the libavcodec.so library under /usr/local/lib and header files under /usr/local/include/ffmpeg.
You probably need to do one more step.
Make sure you have 'root' priviledges for the next steps.
Open the file /etc/ld.so.conf in your favorite text editor.
Add this line of text if it is not already there - otherwise go to the next step (ldconfig).
/usr/local/lib
Run the command 'ldconfig'.
Motion should now be able to find the shared library for ffmpeg in /usr/local/lib.
You can also find a pre-compiled binary package (e.g. rpm or deb) and install this. Normally an rpm will place the libavcodec.so under /usr/lib.
Motion then need to be built by running ./configure, make and make install.
(Note
that with earlier versions of motion you had to specify the location of libavcodec.
Now configure searches for the shared library in /usr/lib and /usr/local/lib
by default.)
The ffmpeg_cap_new option generates a new film at the beginning of each new 'event' and appends to the film for each motion detected within the same event. The current 'event' ends when the time defined by the 'gap' option has passed with no motion detected. At the next detection of motion a new mpeg film is started. Default: off.
The ffmpeg_cap_motion works like ffmpeg_cap_new but outputs motion pictures instead. Default: off.
The ffmpeg_timelapse uses ffmpegs libavcodec to encode a timelaps movie saving a picture frame at the interval in seconds set by this parameter. Setting this option to 0 disables it. The feature gives your viewer the chance to watch the day pass by. It makes a nice effect to film flowers etc closeup during the day. Options like frame_rate, snapshot, gap etc has no impact on the ffmpeg timelapse function. (note: option name ffmpeg_timelapse was renamed to correct spelling in v. 3.1.14 - adding the 'e' at the end)
The ffmpeg_timelapse_mode defined the file rollover mode. Ie. when to close the current timelapse file and start a new one. Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual. it is important that you use the conversion specifiers in ffmpeg_filename that ensure that the new timelapse file indeed is a new file. If the filename does not change Motion will simply append the timelapse pictures to the existing file.
The option ffmpeg_bps sets the bits per seconds of the generated film. The higher value - the better quality - the bigger file. Experiment to get the desired quality/file sizes. Default is 400000 bps.
The option ffmpeg_filename defines the file path and file name for motion triggered ffmpeg films (mpeg) relative to
target_dir. Default: %v-%Y%m%d%H%M%S.
Default value is equivalent to legacy 'oldlayout' option
For
Motion 3.0 compatible mode (directories based on date and time) choose:
%Y/%m/%d/%H%M%S
File extension .mpg is automatically added so do not include
this
This option uses conversion specifiers which are codes that start by %
and then a letter. The conversion specifiers used has the same function as for
the C function strftime (3). The most commonly used are: %Y = year, %m = month
as two digits, %d = date, %H = hour, %M = minute, %S = second. Two are unique to
motion %v = event, %q = frame number. With a combination of text and conversion
specifiers you have full flexibility to define your directory- and filenames.
For a full list of conversion specifiers look in the man page for strftime (man
3 strftime).
If you are happy with the directory structures the way they were
in earlier versions of motion use %v-%Y%m%d%H%M%S for 'oldlayout on' and
%Y/%m/%d/%H%M%S for 'oldlayout off'.
If you want to use this feature you can read about the FFmpeg Streaming Multimedia System
Before you start - consider using ffmpeg instead. It is a much more up to
date way to generate mpegs and ffmpeg has much more features.
It is being
considered removing support for the mpeg_encode in a future version of Motion.
If you would like to keep this feature in the future let us know on the Motion
Mailing List.
To use this feature you need to install the Berkeley
mpeg_encode program.
The program is pretty old (1995) and there has been
some problems with compiling the source code. There is a guy doing an exciting
project called AMIDE.
This project includes the mpeg_encode program and it seems that the author of
AMIDE has polished the old mpeg_encode a little bit calling it 1.5c. The author
has placed 2 versions. A binary only RPM for the Intel 386 platform and two
RPMs with full source. I installed just the binary RPM from the AMIDE site and
it worked fine. The binary RPM contains only two files: mpeg_encode itself which
it installs in /usr/bin and a manual page. Motion looks for the mpeg_encode
in /usr/bin per default. You can change this by setting config file option mpeg_encode_bin.
The feature itself works like this:
Every time motion detects motion a jpg picture is stored. This happens at the framerate you have specified with the 'framerate' option (or at the interval set by the 'minimum_gap' option if different from zero). When the event is over (time defined by the 'gap' option) motion generates a small mpg film using mpeg_encode. This is important to notice when you test the feature the first time. You will have to wait the period defined by 'gap' before you see the mpg file on your disk. If you have used a small framerate or used the minimum_gap option the film is going to be over in a split second. For this feature to be useful you should let motion store pictures almost real time. To generate better films you can play with options like 'post_capture' which will take extra picture after a motion is detected to create better floating films and 'adjust_rate' which will try to generate a 25 fps film. To avoid your harddisk from getting full because a bird is hopping around on the lawn, there are two parameters you can use. 'jpg_cleanup' will delete all the jpg files once the mpeg has been generated. 'max_mpeg_time' limits the duration of an mpeg film to the number of seconds you specify.
The following motion.conf settings controls the Berkeley mpeg_encode feature and shows the typical setting one would choose
############################################################ # Film (mpeg) File Output - Berkeley mpeg_encode Based ############################################################ #Use mpeg_encode from berkeley to encode movies (default: off) mpeg_encode on #Path to the mpeg_encode binary (default: /usr/bin/mpeg_encode) mpeg_encode_bin /usr/bin/mpeg_encode #Adjust the number of frames for an mpeg movie (only mpeg_encode) to get 25fps (default: off) adjust_rate on #Delete jpeg images after they have been converted to movies by mpeg_encode (default: off) #This option is only used when mpeg_encode is on jpg_cleanup on
Important! The Berkeley mpeg_encode feature requires that the motion.conf options for target_dir and filenames follows some strict rules:
The reason is that mpeg_encode needs to know where to find the jpegs and
it depends on details in the filenames to build the mpeg.
These are the motion.conf
options to watch out for.
#File path for motion triggered images (jpeg or ppm) relative to target_dir #Default: %v-%Y%m%d%H%M%S-%q #Default value is equivalent to legacy oldlayout option #For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q #File extension .jpg or .ppm is automatically added so do not include this #For use of Berkeley mpeg_encode this parameter but be set as follows: #If berkeley_single_directory = on: %v-%Y%m%d%H%M%S-%q #If berkeley_single_directory = off: %Y/%m/%d/%H/%M/%S-%q jpeg_filename %v-%Y%m%d%H%M%S-%q #Use single directory structure (For Berkeley mpeg_encode feature only) #on = place mpeg_encode file in target_dir with name YYYYMMDDHHMMSS-n #off (default) = place files as target_dir/YYYY/MM/DD/SS-n berkeley_single_directory off
Motion can also act like a traditional web camera.
The option 'snapshot_interval' enables the snapshots feature by being set to a value different than 0. The value gives the number of seconds between each snapshot.
See the 'snapshot_filename' option in the section 'Advanced Filenames'.
Text features have been made highly flexible starting from version 3.1.13
of Motion. It enables you to
taylor the text displayed on the images and films to your taste and to add your own user defined
text. From version 3.1.13 all text related motion.conf options have been redefined
and renamed.
There are 3 motion.conf options that controls the display of text.
############################################################ # Text Display # %Y = year, %m = month, %d = date, # %H = hour, %M = minute, %S = second, %T = HH:MM:SS # %v = event, %q = frame number, \n = new line # You can put quotation marks around the text to allow # leading spaces ############################################################ #Locate and draw a box around the moving object (default: off) locate off #Draws the timestamp using same options as C function strftime(3) #Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock #Text is placed in lower right corner text_right %Y-%m-%d\n%T #Draw a user defined text on the images using same options as C function strftime(3) #Default: Not defined = no text #Text is placed in lower left corner text_left CAMERA 1\nFRONT DOOR #Draw the number of changed pixed on the images (default: off) #Will normally be set to off except when you setup and adjust the motion settings #Text is placed in upper right corner text_changes off
The text_left and text_right options have the same feature.
text_left
places text in the lower left corner and aligns the text to the left. If the
option is not defined the default is no text displayed.
text_right places
text in the lower right corder and aligns the text to the right. If the option
is not defined the default is showing date in ISO format YYYY-MM-DD and below
this the time as a 24 hour clock HH:MM:SS. If you wish to have no text to the
right define text_right to an empty string "".
text_changes is a feature meant for helping adjusting the threshold and noise_level settings. It shows the number of pixels seen as motion in the upper right corner.
This is how the text is located.
|
Both text_left and text_right are highly flexible.
The user defined text
can be the english alphabet and a selection of symbols - (A-Z, a-z, 0-9, "
/ ( ) @ ~ # < > | , . : - + _ \n) and conversion specifiers. Non-english
characters are for the moment not supported.
A conversion specifier is a code that starts by % (except newline which is \n). The conversion specifiers used has the same function as for the C function strftime (3). The most commonly used are: %Y = year, %m = month as two digits, %d = date, %H = hour, %M = minute, %S = second, %T = HH:MM:SS. Two are unique to motion %v = event, %q = frame number. With a combination of text, spaces, new lines \n and conversion specifiers you have some very flexible text features. For a full list of conversion specifiers see the section 'Conversion Specifiers for Advanced Filename and Text Feature'.
You are allowed to put the text in quotation marks. This allows you to use leading spaces. By combining spaces and new lines '\n' you can place your text anywhere on the picture. Experiment to find your preferred look. When setting the text using motion-control to send XML-RPC commands put the text in quotation marks "" to allow for spaces and new lines.
From version 3.1.13 the old_layout option has been replaced by new advanced options: snapshot_filename, jpeg_filename, ffmpeg_filename, timelapse_filename and predict_filename.
The Berkeley mpeg_encode feature does not support the advanced filenames. There is a new option called 'berkeley_single_directory' which is equivalent to the legacy 'old_layout' options but only used for mpeg_encode. NOTE! When using the Berkeley mpeg_encode feature the 'jpeg_filename' MUST be defined to a specific value depending on the option 'berkeley_single_directory'. See the section 'Generating MPEG films Berkeley mpeg_encode' for detailed information. It is recommended to use the newer ffmpeg feature to generate mpegs since it is much more efficient and has more features.
These are the advanced filename options in motion.conf
############################################################ # Target Directories and filenames For Images And Films # For the options snapshot_, jpeg_, mpeg_ and timelapse_filename # you can use conversion specifiers # %Y = year, %m = month, %d = date, # %H = hour, %M = minute, %S = second, # %v = event, %q = frame number # Quotation marks round string are allowed. ############################################################ #Target base directory for pictures and films target_dir /usr/local/apache2/htdocs/cam1 #File path for snapshots (jpeg or ppm) relative to target_dir #Default: %v-%Y%m%d%H%M%S-snapshot #Default value is equivalent to legacy oldlayout option #For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot #File extension .jpg or .ppm is automatically added so do not include this. #Note: A symbolic link called lastsnap.jpg created in the target_dir will always #point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap' snapshot_filename %v-%Y%m%d%H%M%S-snapshot #File path for motion triggered images (jpeg or ppm) relative to target_dir #Default: %v-%Y%m%d%H%M%S-%q #Default value is equivalent to legacy oldlayout option #For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q #File extension .jpg or .ppm is automatically added so do not include this #For use of Berkeley mpeg_encode this parameter but be set as follows: #If berkeley_single_directory = on: %v-%Y%m%d%H%M%S-%q #If berkeley_single_directory = off: %Y/%m/%d/%H/%M/%S-%q jpeg_filename %v-%Y%m%d%H%M%S-%q #File path for motion triggered ffmpeg films (mpeg) relative to target_dir #Default: %v-%Y%m%d%H%M%S #Default value is equivalent to legacy oldlayout option #For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S #File extension .mpg is automatically added so do not include this ffmpeg_filename %v-%Y%m%d%H%M%S #File path for timelapse mpegs relative to target_dir (ffmpeg only) #Default: %v-%Y%m%d-timelapse #Default value is equivalent to legacy oldlayout option #For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse #File extension .mpg is automatically added so do not include this timelapse_filename %v-%Y%m%d-timelapse #Use single directory structure (For Berkeley mpeg_encode feature only) #on = place mpeg_encode file in target_dir with name YYYYMMDDHHMMSS-n #off (default) = place files as target_dir/YYYY/MM/DD/SS-n berkeley_single_directory off #File path for prediction files. (Default: %v-%Y%m%d%H%M%S) #Default value is equivalent to legacy oldlayout option #For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S #File extension .desc is automatically added so do not include this predict_filename %v-%Y%m%d%H%M%S
The option 'target_dir' is the target directory for all snapshots, motion images
and normal images. The default is the current working directory (current working
directory of the terminal from which motion was started). You will normally
always want to specify this parameter either as a command line option or in the
config file. Use an absolute directory path (not relative) if you want to use
mpeg_encode.
Note that the options snapshot_filename, jpeg_filename,
ffmpeg_filename, timelapse_filename and predict_filename all allows specifying
directories. These will all be relative to 'target_dir'. This means in principle
that you can specify target_dir as '/' and be 100% flexible. It also means that
Motion can write files all over your harddisk if you make a mistake. It is
recommended to specify the target_dir as deep or detailed as possible for this
reason.
The Berkeley mpeg_encode feature still demands that the target_dir
points directly to the real target directory.
The xxxx_filename options all support the 'Conversion Specifiers for Advanced Filename and Text Features'. This means that you can build up the filenames anyway you want using fixed text, conversion specifiers for time, event and frame.
NOTE: Unless you use the 'minimum_gap' option to limit the number of shots to less then one per second - you must use the frame modifier %q as part of the jpeg_filename. Otherwise the pictures saved within the same second will overwrite each other. The %q in 'jpeg_filename' ensures that each jpeg (or ppm) picture saved gets a unique filename.
The table below shows all the supported Conversion Specifiers you can use in the options text_left, text_right, snapshot_filename, jpeg_filename, ffmpeg_filename, timelapse_filename and predict_filename.
In text_left and text_right you can additionally use '\n' for new line.
Conversion Specifier | Description |
%a | The abbreviated weekday name according to the current locale. |
%A | The full weekday name according to the current locale. |
%b | The abbreviated month name according to the current locale. |
%B | The full month name according to the current locale. |
%c | The preferred date and time representation for the current locale. |
%d | The day of the month as a decimal number (range 01 to 31). |
%D | Equivalent to %m/%d/%y. (Yecch - for Americans only. Americans should note that in other countries %d/%m/%y is rather common. This means that in international context this format is ambiguous and should not be used.) |
%E | Modifier: use alternative format, see below. |
%F | Equivalent to %Y-%m-%d (the ISO 8601 date format). |
%H | The hour as a decimal number using a 24-hour clock (range 00 to 23). |
%I | The hour as a decimal number using a 12-hour clock (range 01 to 12). |
%j | The day of the year as a decimal number (range 001 to 366). |
%k | The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.) |
%l | The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.) |
%m | The month as a decimal number (range 01 to 12). |
%M | The minute as a decimal number (range 00 to 59). |
%p | Either 'AM' or 'PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as `pm' and midnight as `am'. |
%P | Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale. |
%q | Picture frame number within current second. For jpeg filenames this should always be included in the filename if you save more then 1 picture per second to ensure unique filenames. It is not needed in filenames for mpegs. |
%r | The time in a.m. or p.m. notation. |
%R | The time in 24-hour notation (%H:%M). |
%s | The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC. |
%S | The second as a decimal number (range 00 to 61). |
%T | The time in 24-hour notation (%H:%M:%S). |
%u | The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w. |
%U | The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W. |
%v | Event number. An event is a series of motion detections happening with less than 'gap' seconds between them. |
%V | The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W. |
%w | The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u. |
%W | The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01. |
%x | The preferred date representation for the current locale without the time. |
%X | The preferred time representation for the current locale without the date. |
%y | The year as a decimal number without a century (range 00 to 99). |
%Y | The year as a decimal number including the century. |
%z | The time-zone as hour offset from GMT. |
%Z | The time zone or name or abbreviation. |
Motion has a mini (very very mini) http server built in. Each thread can have its own webserver. If you enable the webcam server (option webcam_port to a number different from 0) and you have threads you must make sure to include webcam_port to different ports or zero (disable) in each thread config file. Otherwise motion will crash because each webcam server will use the setting from the motion.conf file and try to bind to the same port.
Note: The webcam server feature requires that the option 'ppm' is set to off. (I.e. saved images are jpeg images).
These are the special webcam parameters.
############################################################ # Live Webcam Server ############################################################ #The mimi-http server listens to this port for requests (default: 0 = disabled) webcam_port 8081 #Quality of the jpeg images produced (default: 30) webcam_quality 50 #Only output frames if motion is detected (default: off) webcam_motion off #Maximum framerate for webcam streams (default: 100) webcam_maxrate 1 #Restrict webcam connections to localhost only (default: on) webcam_localhost off #Limits the number of images per connection (default: 0 = unlimited) #Number can be defined by multiplying actual webcam rate by desired number of seconds #Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate webcam_limit 1200
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. You cannot watch the stream with most browsers. Editor has tried Internet Explorer 6, Netscape 6.2 (windows) and Konqueror. Only Netscape on Linux can show the stream. For public viewing this is not very useful. There exists a java applet called Cambozola. Same tool is also used in the motion.cgi program that is available from the motion homepage. 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=400 height=300>
<param name=url value=http://www.myurl.com:8081>
</applet>
Where the width and height is the area of the applet. Adjust it to the same
size or a little larger than your streamed image.
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. Or copy it from motion.cgi package. It is the same version.
4. Enable the feature in motion.conf.
Motion version 3.1.12 has got a new exciting feature which is the ability to control Motion while it is running. Motion now has a built in http server called xmlrpc-httpd. This listens on a port specified by the new 'control_port' config file option. The control protocol is called xml-rpc. With Motion there is a small program that can be built and which can be used to control all the new control features of Motion.
First, the xmlrpc stuff we need to install is located here: http://xmlrpc-c.sourceforge.net/downloading.php
Latest XMLRPC-C version is 0.9.10 (not 0.9.9 as their homepage suggests)
At
Sourceforge you find the latest files.
http://sourceforge.net/project/showfiles.php?group_id=16847
If you use a distribution using RPM like Red Hat
and many other all you need is to download and installed RPMs.
The two
RPMs you need are here
http://prdownloads.sourceforge.net/xmlrpc-c/xmlrpc-c-0.9.10-1.i386.rpm?download
http://prdownloads.sourceforge.net/xmlrpc-c/xmlrpc-c-devel-0.9.10-1.i386.rpm?download
Additionally
the two RPMs above need w3c-libwww installed. The RPMs for w3c-libwww comes
with RedHat but are not installed per default.
For RedHat 9.0 they are on CD
number 3. There are 3 RPMs: w3c-libwww-5.4.0-4.i386.rpm, w3c-libwww-apps-5.4.0-4.i386.rpm
and w3c-libwww-devel-5.4.0-4.i386.rpm.
Previous versions of RedHat also have
the 3 RPMs on the CDs but in earlier versions. They are probably also OK. The
version should not be very critical.
For those that do not use distribution based on RPM, the source tar.gz is
here
http://prdownloads.sourceforge.net/xmlrpc-c/xmlrpc-c-0.9.10.tar.gz?download
There is however a problem with the package above. It will not compile with
gcc compiler version 3.1 and later. Kenneth Lavrsen has patched up the sources
with patches found on the Sourceforge xmlrpc-c patch tracker. This patched package
has been placed in the Motion Sourceforge Files area under "Related Projects"
It is recommended that you download and install this instead.
http://prdownloads.sourceforge.net/motion/xmlrpc-c-0.9.10-kjl1.tar.gz?download
The Libwww can be downloaded from here
http://www.w3c.org/Library/
Follow the installation instructions from the websites of the XMLRPC-C and Libwww libraries.
After installation of xmlrpc-c you need to re-install motion going through all the steps configure, make and make install
Besides building motion with XML-RPC support it also build a small application called motion-control which is copied to /usr/local/bin.
The motion-control program is easy to use. Run it without any parameters and it displays the help.
The command are shown below. Note the following. If you choose to set configuration
parameters for thread 0, all threads will be changed. The individual camera
threads are numbered 1,2,3....
Configuration parameters are simply named
the same as in the motion.conf file. Parameters that are global and not set
in a thread config file can only be read from thread 0. Trying to read a global
only value from a camera thread will give no value back (same reply as if you
ask for a non-existing value). Once you set a value for a thread other than
0 you can read it again from that thread.
The detection pause feature disables
the saving of pictures, snapshots etc but does not stop the webcam server. The
motion-control action and detection features do not work globally. I.e. 'motion-control
action snapshot 0' does not generate snapshots for all cameras. One exception
is 'motion-control action quit' which simply makes motion stop running (all
processes quit).
The conf
write feature overwrites both the motion.conf and the thread config files
in a shorter format with less comments. If you like to keep your config files
make sure to save copies of them before you run this control command. If you
have changed parameters using the conf set command it is the changed values
that get saved to the config files. Global (thread 0) parameters to motion.conf
and individual thread values to the thread config files. Files are saved at
the same location as they were read from overwriting the existing files.
Command |
Description |
motion-control info |
Brief information about motion version and number of threads running. |
motion-control conf list |
List all configuration parameters/options with their type and a short help text. Not all parameters have a help text yet. |
motion-control conf get [threadnr] [parameter] |
Get the value of a configuration parameter for a given thread. Thread 0 means the global or default value. If a parameter is not defined for a given thread then this value will be used instead as a default value. |
motion-control conf set [threadnr] [parameter] [value] |
Set the value of a configuration parameter for a given thread. Thread 0 means the global or default value. If a parameter is not defined for a given thread then this value will be used instead as a default value. |
motion-control conf write |
Write all motion config files. Both the motion.conf and all thread config files. Note that this overwrites the original config files. All old comments are lost. |
motion-control action makemovie [threadnr] |
Make an mpeg movie from jpegs using the mpeg_encode tool on a given thread. |
motion-control action snapshot [threadnr] |
Save a snapshot picture of a given thread. |
motion-control action quit |
Make motion quit completely. Useful for stopping motion when it runs as a daemon. |
motion-control detection pause [threadnr] |
Disables the saving of pictures, snapshots etc for a given thread but does not stop the webcam server. |
motion-control detection resume [threadnr] |
Resume the saving of pictures, snapshots etc for a given thread. |
motion-control track auto [threadnr] [value] |
Enable auto tracking. 0=disabled, 1=enabled. Auto tracking is always disabled when motion starts. Manual tracking is still possible when auto tracking is turned off. |
motion-control track set [threadnr] [value_x] [value_y] |
Turn camera to a specific position. Values x and
y are in degrees from center. Up and right are positive numbers,
Down and left are negative numbers. If you want to move the camera
in one dimension and leave the other unchanged set the value for
the one to be unchanged to an out of range value such a 1000. |
motion-control track pan [threadnr] [value] |
Turn camera to a position in degrees relative to current position. Value is in degrees and positive values means turn right, negative means turn left.. This is a good command for small step sizes like 10-20 degrees. If value is out of range camera will move as far as it can. |
motion-control track tilt [threadnr] [value] |
Tilt camera to a position in degrees relative to current position. Value is in degrees and positive values means tilt up, negative means tilt down. This is a good command for small step sizes like 5-10 degrees. If value is out of range camera will move as far as it can. |
The 'conf set [threadnr] [parameter] [value]' feature is very smart for trying tuning settings and for changing the user defined on screen display.
In motion.conf there is now a new option called 'control_localhost'. By setting this to "on" or "on" Motion can only be controlled via xml-rpc from the same machine on which Motion is running. If you need more refined access control use your firewall such as ipchains or iptables for it.
As mentioned above there is a config file option called 'control_port'. You should normally set this to 8080. If you need to set it to another port you will also need to change the port number defined in the motion-control source file. Look for the line #define MOTION_URL "http://localhost:8080". Same line can be changed to a real URL so that you can control Motion from a remote machine.
This is still at the experimental stage. Read more about it motion tracking page.
Motion supports controlling the pan and tilt
feature of a Logitech Quickcam Sphere/Orbit.
Motion can move the camera to
a fixed position given in degrees pan (left-right) and tilt (down-up). Movement
can be set with absolute coordinates or relative to current position. There
is also an auto tracking feature for the Logitech Quickcam Sphere/Orbit but
it is not very mature. It is fun to play with but not very useful yet.
Motion always starts up with auto tracking turned off.
All control is done using the XML-RPC interface. The actual XML-RPC commands are described in the xmlrpc-api.html document which is part of the distribution and also available on the motion website. The motion-control commands available are:
For a detailed description of XML-RPC see the section 'Controlling Motion via xml-rpc'.
Motion can execute external command based on the events.
These are the options:
############################################################ # External Commands, Warnings and Logging: ############################################################ #Output less information and don't sound beeps when detecting motion (default: off) quiet on #Always display the difference between captured and reference frame (default: off) always_changes off #Email address to send a warning to when detecting motion (default: none) ; mail value #External command to be executed when detecting motion (default: none) ; execute value #Number to send an sms to with sms_client (default: none) ; sms value #Command to be executed each time an image is saved (default: none) ; onsave value #Command to be executed each time an mpeg movie is created (default: none) ; onmpeg value #Command to be executed each time a file generated by ffmpeg is closed (default: none) ; onffmpegclose value
The option 'quiet' is only active when Motion is running in non-daemon mode. When this option is set to 'off' and Motion is running as non-daemon Motion generates a system beep when motion is detected.
The option 'always_changes' is also only working in non-daemon mode. When activated it constantly shows the number of image pixels changed. See 'Tuning Motion for more information'. Normally you set this option to 'off'
The option mail - when defined - sends an email when motion is detected. Argument is an email address in the normal form name@domain.name. An e-mail is sent for each event. Not each picture.
The option sms sends an SMS when motion is detected. The argument is the number to send an SMS to with sms_client. Default: none. Not a feature that has received much attention recently. If you live in GSM land you are probably better off using the e-mail to SMS gateway that most GSM providers have using your mail client. For more information see the sms_client home page.
The option 'onsave' executes the command given when an image is saved. The name of the image will be given as argument. Default: not set. You should give the full path name of the program/script. This can be any type of program or script. Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash also remember the shebang line (e.g. #!/user/bin&perl) as the first line of the script.
The option 'onmpeg' executes the command given when an mpeg movie is generated. The name of the movie will be given as argument. Default: not set. You should give the full path name of the program/script. This can be any type of program or script. Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash also remember the shebang line (e.g. #!/user/bin&perl) as the first line of the script. This feature works best with mpeg movies generated by the Berkeley mpeg encode. When you use ffmpeg the film is generated on the fly instead of from jpeg pictures and onmpeg then runs before the film is actually saved. It is therefore better to use the onffmpegclose option with ffmpeg.
The option 'onffmpegclose' executes the command given when an ffmpeg movie is closed at the end of an event. The name of the movie will be given as argument. Default: not set. You should give the full path name of the program/script. This can be any type of program or script. Remember to set the execution bit in the ACL and if it is a script type program such as perl or bash also remember the shebang line (e.g. #!/user/bin&perl) as the first line of the script. The command is run when an event is over. I.e. the number of seconds defined by the time 'gap' has passed since the last detection of motion and motion closes the mpeg file
Motion can be compiled with both MySQL and PostgreSQL database support. When
enabled Motion adds a record to a table in the database with fields for filename
and time. it also write a field called type. Motion does not place any binary images in the database and it cannot
remove old records.
Motion only adds records to the database when files are
created. The database contains records of saved files which means to get a record
in the database the feature that enables for example motion detection, timelapse,
snapshots etc must be enabled. The sql_log options defines which types of files
are logged in the database.
The following sql_log options are common to both MySQL and PostgreSQL.
############################################################ # Common Options For MySQL and PostgreSQL database features. # Options require the MySQL/PostgreSQL options to be active also. ############################################################ #Log to the database when creating motion triggered image file (default: on) sql_log_image on #Log to the database when creating a snapshot image file (default: on) sql_log_snapshot on #Log to the database when creating motion triggered mpeg file (default: off) sql_log_mpeg on #Log to the database when creating timelapse mpeg file (default: off) sql_log_timelapse on #Log to the database when creating a prediction file (default: off) sql_log_prediction off
See the "Using MySQL" section for detailed information about the database itself.
You can use the MySQL database to register each file that is stored by motion. What is stored is the
filename (full path), and the time.
You need to generate a new database with
a name of your own choice. You must enter this name in the config file (mysql_db
option). Select the new database in MySQL and create a new table "security"
with the following fields:
These are the file type descriptions and the file type numbers stored in the database.
Normal image |
1 |
Snapshot image |
2 |
Motion image (showing only pixels defined as motion) |
4 |
Normal mpeg image |
8 |
Motion mpeg (showing only pixels defined as motion) |
16 |
Timelapse mpeg |
32 |
Prediction file |
64 |
You can create the table using the following SQL statement.
CREATE TABLE security (filename char(60) not null, minute int, hour int, day int, month int, year int, type int);
Remember to update grant table to give access to the mysql username you choose
for motion.
Note that motion does not store the seconds so you have have
many files saved with the same time stamp. To get the exact time you will need
to extract that from the file name.
It would be too much to go into detail about how to setup and use MySQL. After all this is a guide about Motion. However here are some hints and links.
Setting
Up a MySQL Based Website A beginners guide from Linux Planet.
Webmonkey
PHP/MySQL tutorial Entertaining and easy to read.
The phpMyAdmin
homepage. The best and simplest tool to use MySQL (editors opinion). Requires
Apache/PHP.
Same/similar as for MySQL above.
The video4linux device is a Kernel module which installs itself as a video
pipe. It has an input and an output. The module simply takes anything that comes
on its input and send it out at the output. The purpose of this is to create
a standard video4linux type video device that other programs can then use. You
may now ask: "What do I need that for?".
Only one program can access
a video device at a time. When motion is using a camera - no other program can
access the same camera. But motion is made to be able to feed a video signal
to the video loopback device. This way an additional program such as Camstream,
Xawtv, a video stream server etc can watch the signal from a camera that motion
uses already. What you see is not the live camera stream but the exact same
picture that motion uses for detecting motion and the same pictures that are
saved/streamed. You can also choose to see the "motion" type images
where you see the pixels that are changing - live. Originally the video4linux
pipe was used as an interface between Motion and a Webcam server. Since version
2.9 Motion has had its own webserver so this usage is no longer very relevant.
When you install the video loopback device it will create an input - for example /dev/video5 and an output - for example /dev/video6. You can then tell motion to "pipe" the video signal to the /dev/video5 and look at the pictures live using e.g. Camstream on /dev/video6. Camstream is "fooled" to think it is looking at a real camera.
Installing the video loopback device is not difficult. At least not when you have this document available.
First you must prepare your system for more video devices. You will need
two extra devices for each video pipe that you want.
For example if you have
4 cameras they will probably run at /dev/video0, /dev/video1, /dev/video2, and
/dev/video3. So you will need additional 8 video devices. This is easy to do.
mknod /dev/video4 c 81 4
mknod /dev/video5 c 81 5
mknod /dev/video6
c 81 6
mknod /dev/video7 c 81 7
mknod /dev/video8 c 81 8
mknod /dev/video9
c 81 9
mknod /dev/video10 c 81 10
mknod /dev/video11 c 81 11
Note that
the video device number is the same as the last parameter given on each line.
You may need to set the ownership and permissions (chown and chmod) to be the same as the video devices that were already there.
Now you need to install the video loopback device.
When compiling on a newer Linux distribution you may get a warning about
a header file malloc.h. To remove this warning simply change the header
reference as suggested by the warning.
In vloopback.c you replace the
line
#include <linux/malloc.h>
with the line
#include <linux/slab.h>
The Motion Guide author has only very little experience with the feature. At the moment all Motion can do is report recognition as a "Best Guess: Prediction_name value" on the console. Ie. it cannot do anything in Daemon mode. Prediction is controlled by the new 'predict_enable', predict_description' and 'predict_threshold' config file options. This is really experimental code that needs some further work. Once the prediction is working there are many funny features it can be used for where motion can take actions/run scripts/save pictures depending on the kind of motion detected.
These are Jeroen own words for the feature.
prediction is a little experiment I have been doing over the past days...
Using
'description files' that describe a movement. Motion tries to predict what it
was that triggered it. At the moment motion can distinguish between me sitting
at the computer, me walking out of the room and me walking into the room.
A
description is outputted for each event (.desc files). Motion will load files
mentioned with 'predict_description' in the config file. These files have three
lines: a line with the title, a line with the minimum values and a line with
the maximum values. The current version is very rude..... try it, but don't
expect to much
HOWTO make a description file:
The combine program that Jeroen talks about is included in the Motion 3.1.10 distribution both as a Intel-386 binary and as source. To build this little application from source simply run this command.
gcc -o combine combine.c
This creates the combine binary in the Motion directory.
Error logging has been implemented so that
errors during daemon (background) mode are logged in the syslog.
The syslog
is in most Linux systems the file /var/log/messages.
From version 3.0.1 of motion this
guide is now part of the distribution. The jpg files however are not included.
Go to the URL above if you want to see the guide with pictures.
1.5 Added a detailed
description about using the video4linux loopback device with Motion.
1.6
Corrected some details about module loading order in the video loopback section
that was added in 1.5.
1.7 Added fix for filename bug in the mpeg_encode
feature. Added note that ffmpeg sources are currently no longer available at
the ffmpeg site.
1.8 Added a reference to the URL of the original document
in case someone gets a copy in a package or paper copy and wants to see the
latest online.
1.9 Updated for rev 3.0.1. Removed the bugfixes that are now
all fixed in 3.0.1. Added a section describing the new make file options.
1.10
Added method for downloading ffmpeg from the CVS
1.11 Corrected the feature
description of ffmpeg.
1.12 Added a fix for using ffmpeg version 0.4.5. Also
added a link to locations of the ffmpeg-0.4.5.tar.gz file (no guarantee that
it will always be valid). Updated version of motion to 3.0.2. This version does
not yet cover the experimental 3.1.0 version.
1.13 Added even more ffmpeg
0.4.5 download URLs. One of them must work.
1.14 Added note about ffmpeg
and processor type in the ffmpeg section.
1.15 Updated to version 3.0.3.
ffmpeg now fixed. Added the new 3 usertext options and a section to describe
these.
1.16 Updated so that examples shows 3.0.3.
1.17 Clarified that
the timelaps function of ffmpeg generated mpegs is fixed to one shot per minute.
1.18
Updated to version 3.0.4. No changes in this guide except the version.
1.19
Added the new options for experimental version 3.1.2. Added new section with
sub-sections at the end of the document describing the 3.1.2 experimental version.
1.20
Minor cosmetics and removal of two dead ffmpeg links.
1.21 Updated for version
3.1.3.. The following options descriptions were added or improved: debug_parameter,
ffmpeg_cap_motion, ffmpeg_timelaps, mpeg_encode, netcam_url, netcam_userpass,
onmpeg, realconfig (removed), thread, track_speed, track_stepsize, -U, -A (removed).
The following special sections have been improved: ffmpeg, mask file, webcam
server, and experimental version 3.1.2 has become 3.1.3 with many changes and
important bug fix notes. Options in tables have been better alphabetized. Misc
typos corrected.
1.22 Minor clarification of the install commands (/path/to)
based on user feedback.
1.23 Added information in the config file options
section about parameters that are not allowed in the config file without having
the matching software installed (cURL, MySQL, PostgreSQL and ffmpeg).
1.24
Updated the guide for versions 3.0.5 (no changes) and 3.1.4 (less errors to
correct when installing - also NEW errors). ffmpeg section updated.
1.25.
Modified ffmpeg section to only refer to the latest cvs version (which now works
great with Motion). Changed the yes|no to on|off for all boolean type config
parameters to match the autogenerated motion.conf files that motion 3.1.4 can
create using xml-rpc commands. Yes|no are still valid values. So are 1 and 0.
Corrected some errors in the drawtext parameter description.
1.26. Updated
for motion 3.1.5. Workarounds and code tweaking is no longer needed to install
3.1.5. xml-rpc section for 3.1.5 is improved. New 'motion-control action quit'
command added. Commands are now placed in a nice table.
1.27 Corrected mistake
in the mask file section (missing important '-' in djpeg command line)
1.28
Clarified the licensing description so that it is clear that Motion is a General
Public License project.
1.29 Added new parameter "output_all" for
version 3.1.6. The editor cannot understand what it is used for other than filling
up the harddisk with pictures in no time. Updated links to ffmpeg released version
0.4.6 and the ffmpeg latest CVS release.
1.30 Extended the description of
the new output_all feature in the table of options and added a small section
in the end of the document.
1.31 Added a fix for how to compile Motion without
xml-rpc in version 3.1.6 (from Motion mailing list posting from Emilio Paulini).
1.32
Added "Known Problems" section with link to patches - will be removed
again when/if they (or similar fixes) are included with next release. Added
a reference to all those nice people on the mailing list in the "How do
I get.." section.
1.33 Small improvement in the explanation of the webcam_motion
option.
1.34 Updated for versions 3.0.6 and 3.1.7. Important changes are
- roundrobing option has been corrected to the correct spelling roundrobin in
the 3.1.7 version only. This impacts your old motion.conf files. Kenneth Lavrsen's
patches are no longer needed as they are now included in both releases. Workaround
needed for 3.1.X when not having xml-rpc installed has removed. It is no longer
needed in 3.1.7.
1.35 Do not try 3.1.7 yet. There is an error in picture.c
that prevents you from compiling it. Fix should be ready any time.
1.36 Fix
for 3.1.7 added. See Known Problems section. Added information about the fact
that the webcam feature and ppm on is not compatible.
1.37 Improved the description
of the 'input' config parameter (-i command line parameter).
1.38 Updated
for version 3.1.8. This fixes the compiler error that 3.1.7 had.
1.39 Fix
for wrong version in 3.1.7 simplified by using autoconf if available.
1.40
Added fix for the often reported 'ioctl (VIDIOCGCHAN): Invalid argument'. See
known problems section.
1.41 Corrected a typo in the known problems section:
'inout' -> 'input'. Patch file was and is OK.
1.42 As a result of good
feedback from users I have a updated the guide to better explain the config
files (thanks Peter)
1.43 Corrected the order in which Motion looks for its
config file and also correct the path name for the $HOME/.motion directory.
Improved the language in the 'How to Install Motion' section.
1.44 Updated
the "Known Problems" section and added new patch that addresses both
the 'ioctl (VIDIOCGCHAN): Invalid argument' and segmentation fault when saving
motion type mpegs using ffmpeg. Hopefully this patch will no longer be needed
when next versions of Motion are released.
1.45 Extended the Known Problems
section with fix for compatibility with ffmpeg 0.4.8. Current stable version
is now 3.0.7. Installation of XMLRPC-C library used for 3.1.8 is extended per
request from users.
1.46
Updated for release 3.0.7 which is a clean bugfix release that clears out the
"known problem". MySQL section simplified as some old warnings are
not really relevant anymore.
1.47 Updated for release 3.1.10. New features
for 3.1.10 only! The error logging now
happens into the syslog. This means that you can see the errors than happened
when running in daemon mode also. The other new feature is that the cpu_low
option is no longer an on/off option but a parameter than can have value 0 =
off and integers larger than 0 is the framerate that Motion runs when not detecting
motion. This value should be lower than the framerate set for the camera to
make sense.. Additionally
improvements of performance in file creations, optimized rgb conversion, and
differences search, improved memory handling and removal of memory leak.
1.48
3.1.10 and 3.0.7 and most earlier versions have a memory leak in the webcam
feature. Added reference to a fix for it.
1.49 Tried to improve the process
of building with ffmpeg support. Added warning about CURL library version (libcurl)
in the known problems section.
1.50 Updated for release 3.1.12 including
the new option pre_record and the new pan/tilt XML-RPC commands.
2.0 Complete
rewrite of the Guide. Version before 3.1.13 no longer supported by this manual
(it was getting too confusing to cover the many versions). For legacy versions
of Motion use the Motion Guide found in version 3.1.12.
2.1 Added the /etc/ld.so.conf
and ldconfig steps to the installation of ffmpeg.
2.2 Corrected the spelling
of timelapse (was timelaps) in both guide, source code and option names in config
files.
Added descriptions of the new features and options: ffmpeg_timelapse_mode,
minimum_motion_frames, and the 5 new sql_log_xxx options. This includes a new
section 'Using Databases'.