cd /usr/local tar -xvzf /path/to/motion-3.2.X.tar.gz
ln -s motion-3.2.X motion
cd motion
./configure
make
make install
motion
sudo apt-get install motionThe debian packages install the Motion config file in
/etc/motion/motion.conf
which is the correct location when Motion runs as a daeson under a system user. If you want to run Motion under your own username you need to copy the config file to our Home folder so that the master copy won’t be affected. Open a terminal and copy the configuration file to your Home folder with following commands:
mkdir .motion(Note: This will create a hidden folder
.motion
in your Home directory.)
sudo cp /etc/motion/motion.conf ~/.motion/motion.conf(Note: This command will copy the original motion configuration file to its location.) Now can open the configuration file for editing. Change directory to the location of the motion.conf and run
sudo nano motion.confAfter you you have done so, start motion in the terminal simply by typing:
sudo motion
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 |
Library | RPM Packages | Debian Packages |
---|---|---|
libavcodec, libavformat | ffmpeg and ffmpeg-devel or install from source | libavcodec-dev libavcodec0d libavformat-dev libavformat0d (*) |
deb http://www.deb-multimedia.org stable main # ( etch ) deb http://www.deb-multimedia.org testing main # ( lenny ) deb http://www.deb-multimedia.org unstable main # ( sid )Add the suitable line to your /etc/apt/sources.list and run this:
apt-get update ; apt-get -y install libavcodec-dev libavcodec0d libavformat-dev libavformat0dFor logging in MySQL you need this library:
Library | RPM Packages | Debian Packages |
---|---|---|
libmysqlclient | mysql and mysql-devel | libmysqlclient15-off and libmysqlclient15-dev |
Library | RPM Packages | Debian Packages |
---|---|---|
libpq | postgresql-libs and postgresql-devel | libpq-dev and libpq4 |
./configure
You can add the parameter ./configure --help
to get help on the different switches.
This is walk through of the options.
make
before, you should run a make clean
before running make
again. This cleans out all the object files that were generated the previous time you ran make
. If you do not run make clean
first before you rebuild Motion you may not get the additional feature included. For example: If you built Motion without ffmpeg support and then add it later - and rebuild Motion without running make clean
first - the ffmpeg feature does not get compiled into the Motion binary.
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)(path shown are the defaults): /usr/local/bin, usr/local/man/man1, /usr/local/etc, /usr/local/share/doc/motion-3.2.X, and /usr/local/share/doc/examples/motion-3.2.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) 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.
make
, make install
and make uninstall
has already been described above.
make clean
before you run make
if you change the configuration (like adding features such as ffmpeg) and rebuild motion.
-c pathname
Motion will expect the config file to be as specified. When you specify the config file on the command line with -c you can call it anything.
If you do not specify -c or the filename you give Motion does not exist, Motion will search for the configuration file called 'motion.conf' in the following order:
motion [ -hns ] [ -c config file path ] [ -d level ] [ -p process_id_file ]
Option | Range/Values Default |
Description |
---|---|---|
area_detect | Values: 1 - 999999999 Default: Not defined |
Detect motion center in predefined areas. A script (on_area_detected) is started immediately when motion center is detected in one of the given areas, but only once during an event even if there is motion in a different configured area. Take care: This option does NOT restrict detection to these areas!, Detect motion center in predefined areas. A script (on_area_detected) is started immediately when motion center is detected in one of the given areas, but only once during an event even if there is motion in a different configured area. Take care: This option does NOT restrict detection to these areas! |
auto_brightness | Values: on, off Default: off |
Let motion regulate the brightness of a video device. Only recommended for cameras without auto brightness, Let motion regulate the brightness of a video device. Only recommended for cameras without auto brightness |
brightness | Values: 0 - 255 Default: 0 (disabled) |
The brightness level for the video device., The brightness level for the video device. |
contrast | Values: 0 - 255 Default: 0 (disabled) |
The contrast level for the video device. Disabled (Value 0) means that Motion does not set the contrast value., The contrast level for the video device. Disabled (Value 0) means that Motion does not set the contrast value. |
daemon | Values: on, off Default: off |
Start in daemon (background) mode and release terminal. This option must be placed in motion.conf and not in a thread config file., Start in daemon (background) mode and release terminal. This option must be placed in motion.conf and not in a thread config file. |
database_busy_timeout | Values: 0 .. positive integer Default: 0 |
Database wait time in milliseconds for locked database to be unlocked before returning database locked error (default 0). If the database is busy when the request is issued, this parameter indicates the time to wait before issuing a timeout message, Database wait time in milliseconds for locked database to be unlocked before returning database locked error (default 0). If the database is busy when the request is issued, this parameter indicates the time to wait before issuing a timeout message |
database_dbname | Values: Max 4095 characters Default: Not defined |
The name of the database. For Sqlite3, the full path and name to the database, The name of the database. For Sqlite3, the full path and name to the database |
database_host | Values: Max 4095 characters Default: localhost |
IP address or domain name for the database server. Use "localhost" if motion and the database runs on the same server., IP address or domain name for the database server. Use "localhost" if motion and the database runs on the same server. |
database_password | Values: Max 4095 characters Default: Not defined |
The user password for the database, The user password for the database |
database_port | Values: 1-65535 Default: Not defined |
The port number that is used for the database. Typical values are: mysql=3306 and postgresql=5432 , The port number that is used for the database. Typical values are: mysql=3306 and postgresql=5432 |
database_type | Values: mysql, postgresql, sqlite3 Default: Not defined |
Type of database used. Leave it undefined if you are not using databases, Type of database used. Leave it undefined if you are not using databases |
database_user | Values: Max 4095 characters Default: Not defined |
User account name for database, User account name for database |
despeckle | Values: EedDl Default: Not defined |
Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling., Despeckle motion image using combinations of (E/e)rode or (D/d)ilate. And ending with optional (l)abeling. |
emulate_motion | Values: on, off Default: off |
Always save images even if there was no motion., Always save images even if there was no motion. |
event_gap | Values: 0 - 2147483647 Default: 60 |
event_gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short time-frame., event_gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short time-frame. |
exif_text | Values: Max 4095 characters Default: Empty string |
Use this option to specify the text to include in a JPEG EXIF comment The EXIF timestamp is included independent of this text. , Use this option to specify the text to include in a JPEG EXIF comment The EXIF timestamp is included independent of this text. |
ffmpeg_bps | Values: 0 - 9999999 Default: 400000 |
Bitrate of mpegs produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed., Bitrate of mpegs produced by ffmpeg. Bitrate is bits per second. Default: 400000 (400kbps). Higher value mans better quality and larger files. Option requires that ffmpeg libraries are installed. |
ffmpeg_duplicate_frames | Values: on, off Default: on |
When creating videos, this feature will duplicate frames in order to keep up with the requested frames per second., When creating videos, this feature will duplicate frames in order to keep up with the requested frames per second. |
ffmpeg_output_debug_movies | Values: on, off Default: off |
Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes., Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes. |
ffmpeg_output_movies | Values: on, off Default: off |
Use ffmpeg libraries to encode mpeg movies in realtime., Use ffmpeg libraries to encode mpeg movies in realtime. |
ffmpeg_timelapse | Values: 0 - 2147483647 Default: 0 (disabled) |
Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used., Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used. |
ffmpeg_timelapse_mode | Values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual Default: daily |
The file rollover mode of the timelapse video., The file rollover mode of the timelapse video. |
ffmpeg_variable_bitrate | Values: 0, 2 - 31 Default: 0 (disabled) |
Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst., Enables and defines variable bitrate for the ffmpeg encoder. ffmpeg_bps is ignored if variable bitrate is enabled. Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps, or the range 2 - 31 where 2 means best quality and 31 is worst. |
ffmpeg_video_codec | Values: mpeg4, msmpeg4, swf, flv, ffv1, mov, ogg, mp4, mkv, hevc Default: mpeg4 |
Codec to be used by ffmpeg for the video compression. Timelapse will only work with the options mpeg4 or swf., Codec to be used by ffmpeg for the video compression. Timelapse will only work with the options mpeg4 or swf. |
framerate | Values: 2 - 100 Default: 100 (no limit) |
Maximum number of frames to be captured from the camera per second., Maximum number of frames to be captured from the camera per second. |
frequency | Values: 0 - 999999 Default: 0 (Not set) |
The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it), The frequency to set the tuner to (kHz). Valid range: per tuner spec, default: 0 (Don't set it) |
height | Values: Device Dependent Default: 288 |
The height of each frame in pixels., The height of each frame in pixels. |
hue | Values: 0 - 255 Default: 0 (disabled) |
The hue level for the video device., The hue level for the video device. |
input | Values: -1, 0, 1, 2, 3.... Default: -1 (disabled) |
Input channel to use expressed as an integer number starting from 0. Should normally be set to 0 or 1 for video/TV cards, and -1 (disabled) for USB and network cameras., Input channel to use expressed as an integer number starting from 0. Should normally be set to 0 or 1 for video/TV cards, and -1 (disabled) for USB and network cameras. |
ipv6_enabled | Values: on, off Default: off |
Enable or disable IPV6 for http control and stream, Enable or disable IPV6 for http control and stream |
lightswitch | Values: 0 - 100 Default: 0 (disabled) |
Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity., Ignore sudden massive light intensity changes given as a percentage of the picture area that changed intensity. |
locate_motion_mode | Values: on, off, preview Default: off |
Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie. , Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie. |
locate_motion_style | Values: box, redbox, cross, redcross Default: box |
Set the look and style of the locate box if enabled., Set the look and style of the locate box if enabled. |
log_level | Values: 1-9 Default: 6 |
This option specifies the level of verbosity of the messages sent from Motion. At a level of 8(DBG), there are a LOT of messages. At a level of 1(EMR) virtually no messages will be output. The various levels are [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL)., This option specifies the level of verbosity of the messages sent from Motion. At a level of 8(DBG), there are a LOT of messages. At a level of 1(EMR) virtually no messages will be output. The various levels are [1..9] (EMR, ALR, CRT, ERR, WRN, NTC, INF, DBG, ALL). |
log_type | Values: COR, STR, ENC, NET, DBL, EVT, TRK, VID, ALL Default: ALL |
The different components of Motion use different log types. This option allows the user to only show the messages from particular components., The different components of Motion use different log types. This option allows the user to only show the messages from particular components. |
logfile | Values: Max 4095 characters Default: Not defined |
Use this option to specify the full path and filename to use for logging of the messages generated from Motion. If this option is not defined, the stderr and syslog is used. Note that Motion can generate a LOT of messages and as a result, this option should be considered if the log_level is at any of the higher levels., Use this option to specify the full path and filename to use for logging of the messages generated from Motion. If this option is not defined, the stderr and syslog is used. Note that Motion can generate a LOT of messages and as a result, this option should be considered if the log_level is at any of the higher levels. |
mask_file | Values: Max 4095 characters Default: Not defined |
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. , 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. |
max_movie_time | Values: 0 (infinite) - 2147483647 Default: 3600 |
The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length., The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length. |
minimum_frame_time | Values: 0 - 2147483647 Default: 0 |
Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate., Minimum time in seconds between the capturing picture frames from the camera. Default: 0 = disabled - the capture rate is given by the camera framerate. |
minimum_motion_frames | Values: 1 - 1000s Default: 1 |
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 is 1 to thousands, but it is recommended to keep it within 1-5., 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 is 1 to thousands, but it is recommended to keep it within 1-5. |
motion_video_pipe | Values: Max 4095 characters Default: Not defined |
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, 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 |
movie_filename | Values: Max 4095 characters Default: %v-%Y%m%d%H%M%S |
File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This was previously called ffmpeg_filename., File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This was previously called ffmpeg_filename. |
netcam_keepalive | Values: off, on, force Default: off |
The setting for keep-alive of network socket, should improve performance on compatible net cameras. , The setting for keep-alive of network socket, should improve performance on compatible net cameras. |
netcam_proxy | Values: Max 4095 characters Default: Not defined |
URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber, URL to use for a netcam proxy server, if required. The syntax is http://myproxy:portnumber |
netcam_tolerant_check | Values: on, off Default: off |
Set less strict jpeg checks for network cameras with a poor/buggy firmware., Set less strict jpeg checks for network cameras with a poor/buggy firmware. |
netcam_url | Values: Max 4095 characters written as URL Default: Not defined |
URL to use if you are using a network camera (incl http:// ftp:// mjpg:// rtsp:// mjpeg:// or file:///). Size will be autodetected Must be a URL that returns single jpeg pictures or a raw mjpeg stream. A trailing slash may be required for some cameras., URL to use if you are using a network camera (incl http:// ftp:// mjpg:// rtsp:// mjpeg:// or file:///). Size will be autodetected Must be a URL that returns single jpeg pictures or a raw mjpeg stream. A trailing slash may be required for some cameras. |
netcam_userpass | Values: Max 4095 characters Default: Not defined |
The Username and password for the network camera. For http protocols, this option is for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. To use no authentication simply remove this option. Note that only basic authentication is supported for connection to netwwork cameras. Digest authentication is not currently available , The Username and password for the network camera. For http protocols, this option is for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. To use no authentication simply remove this option. Note that only basic authentication is supported for connection to netwwork cameras. Digest authentication is not currently available |
noise_level | Values: 1 - 255 Default: 32 |
The noise level is used as a threshold for distinguishing between noise and motion., The noise level is used as a threshold for distinguishing between noise and motion. |
noise_tune | Values: on, off Default: on |
Activates the automatic tuning of noise level., Activates the automatic tuning of noise level. |
norm | Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour) Default: 0 (PAL) |
Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL), Select the norm of the video device. Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL) |
on_area_detected | Values: Max 4095 characters Default: Not defined |
Command to be executed when motion in a predefined area is detected. Check option area_detect., Command to be executed when motion in a predefined area is detected. Check option area_detect. |
on_camera_lost | Values: Max 4095 characters Default: Not defined |
Command to be executed when a camera can't be opened or if it is lost. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. (new in 3.2.10), Command to be executed when a camera can't be opened or if it is lost. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. (new in 3.2.10) |
on_event_end | Values: Max 4095 characters Default: Not defined |
Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command., Command to be executed when an event ends after a period of no motion. The period of no motion is defined by option gap. You can use Conversion Specifiers and spaces as part of the command. |
on_event_start | Values: Max 4095 characters Default: Not defined |
Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command., Command to be executed when an event starts. An event starts at first motion detected after a period of no motion defined by gap. You can use ConversionSpecifiers and spaces as part of the command. |
on_motion_detected | Values: Max 4095 characters Default: Not defined |
Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command., Command to be executed when a motion frame is detected. You can use Conversion Specifiers and spaces as part of the command. |
on_movie_end | Values: Max 4095 characters Default: Not defined |
Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command., Command to be executed when an ffmpeg movie is closed at the end of an event. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. |
on_movie_start | Values: Max 4095 characters Default: Not defined |
Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command., Command to be executed when an mpeg movie is created. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. |
on_picture_save | Values: Max 4095 characters Default: Not defined |
Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command., Command to be executed when an image is saved. You can use Conversion Specifiers and spaces as part of the command. Use %f for passing filename (with full path) to the command. |
output_debug_pictures | Values: on, off Default: off |
Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. If a Smartmask is specified, it is shown in red., Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. If a Smartmask is specified, it is shown in red. |
output_pictures | Values: on, off, first, best, center 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 like defined by output_motion. Default is that normal images are stored., 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 like defined by output_motion. Default is that normal images are stored. |
picture_filename | Values: Max 4095 characters Default: %v-%Y%m%d%H%M%S-%q |
File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file., File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file. |
picture_type | Values: jpeg, ppm Default: jpeg |
This option specifies the type of picture file to output., This option specifies the type of picture file to output. |
post_capture | Values: 0 - 2147483647 Default: 0 (disabled) |
Specifies the number of frames to be captured after motion has been detected., Specifies the number of frames to be captured after motion has been detected. |
power_line_frequency | Values: -1, 0, 1, 2, 3 Default: -1 |
This option allows the user to specify the power line frequency that is applicable to the user. This option can help stabilize the images of some webcams that are sensitive to this frequency. This is not normally necessary., This option allows the user to specify the power line frequency that is applicable to the user. This option can help stabilize the images of some webcams that are sensitive to this frequency. This is not normally necessary. |
pre_capture | Values: 0 - 100s Default: 0 (disabled) |
Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead., Specifies the number of previous frames to be outputted at motion detection. Recommended range: 0 to 5, default=0. Do not use large values! Large values will cause Motion to skip video frames and cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead. |
process_id_file | Values: Max 4095 characters Default: Not defined |
File to store the process ID, also called pid file. Recommended value when used: /var/run/motion.pid, File to store the process ID, also called pid file. Recommended value when used: /var/run/motion.pid |
quality | Values: 1 - 100 Default: 75 |
The quality for the jpeg images in percent., The quality for the jpeg images in percent. |
quiet | Values: on, off Default: off |
Be quiet, don't output beeps when detecting motion., Be quiet, don't output beeps when detecting motion. |
rotate | Values: 0, 90, 180, 270 Default: 0 (not rotated) |
Rotate image the given number of degrees. The rotation affects all saved images as well as mpeg movies., Rotate image the given number of degrees. The rotation affects all saved images as well as mpeg movies. |
roundrobin_frames | Values: 1 - 2147483647 Default: 1 |
Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) is possible., Specifies the number of frames to capture before switching inputs, this way also slow switching (e.g. every second) is possible. |
roundrobin_skip | Values: 1 - 2147483647 Default: 1 |
Specifies the number of frames to skip after a switch. (1 if you are feeling lucky, 2 if you want to be safe)., Specifies the number of frames to skip after a switch. (1 if you are feeling lucky, 2 if you want to be safe). |
rtsp_uses_tcp | Values: on, off Default: on |
This option specifies the transport method for rtsp cameras. The TCP transport is highly preferred because without this option the rtsp images are frequently corrupted and result in many false positive values and images that appear to be smeared. Off indicates that UDP will be used., This option specifies the transport method for rtsp cameras. The TCP transport is highly preferred because without this option the rtsp images are frequently corrupted and result in many false positive values and images that appear to be smeared. Off indicates that UDP will be used. |
saturation | Values: 0 - 255 Default: 0 (disabled) |
The colour saturation level for the video device., The colour saturation level for the video device. |
sdl_threadnr | Values: 1-65535 Default: Not defined |
The SDL option is optional and unusual. When SDL is included in the building of Motion, there is the ability for Motion to create a SDL preview window for the user. The author believes this option to be more of a proof of concept on how to create a SDL window and show the image. (This same functionality can be achieved via the stream options) To activate the SDL window, include SDL support in the building of the Motion application. Start Motion and note the thread number indicated. Once that is noted, specify that thread number (or 1 more than that number) for this option. When Motion is started again, it will then create a SDL window to preview the image. To close the window, press X. Author is not aware of any method to restart the SDL window after it has been closed. , The SDL option is optional and unusual. When SDL is included in the building of Motion, there is the ability for Motion to create a SDL preview window for the user. The author believes this option to be more of a proof of concept on how to create a SDL window and show the image. (This same functionality can be achieved via the stream options) To activate the SDL window, include SDL support in the building of the Motion application. Start Motion and note the thread number indicated. Once that is noted, specify that thread number (or 1 more than that number) for this option. When Motion is started again, it will then create a SDL window to preview the image. To close the window, press X. Author is not aware of any method to restart the SDL window after it has been closed. |
setup_mode | Values: on, off Default: off |
Run Motion in setup mode. , Run Motion in setup mode. |
smart_mask_speed | Values: 0 - 10 Default: 0 (disabled) |
Slugginess of the smart mask. Default is 0 = DISABLED. 1 is slow, 10 is fast., Slugginess of the smart mask. Default is 0 = DISABLED. 1 is slow, 10 is fast. |
snapshot_filename | Values: Max 4095 characters Default: %v-%Y%m%d%H%M%S-snapshot |
File path for snapshots (jpeg or ppm) relative to target_dir., File path for snapshots (jpeg or ppm) relative to target_dir. |
snapshot_interval | Values: 0 - 2147483647 Default: 0 (disabled) |
Make automated snapshots every 'snapshot_interval' seconds., Make automated snapshots every 'snapshot_interval' seconds. |
sql_log_movie | Values: on, off Default: off |
Log to the database when creating motion triggered mpeg file., Log to the database when creating motion triggered mpeg file. |
sql_log_picture | Values: on, off Default: on |
Log to the database when creating motion triggered image file., Log to the database when creating motion triggered image file. |
sql_log_snapshot | Values: on, off Default: on |
Log to the database when creating a snapshot image file., Log to the database when creating a snapshot image file. |
sql_log_timelapse | Values: on, off Default: off |
Log to the database when creating timelapse mpeg file, Log to the database when creating timelapse mpeg file |
sql_query | Values: Max 4095 characters Default: insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C') |
SQL query string that is sent to the database. The values for each field are given by using convertion specifiers, SQL query string that is sent to the database. The values for each field are given by using convertion specifiers |
stream_auth_method | Values: 0, 1, 2 Default: 0 |
This parameter establishes desired authentication method for the stream and web control ports. Disabled (0), Basic (1), MD5 Digest (2), This parameter establishes desired authentication method for the stream and web control ports. Disabled (0), Basic (1), MD5 Digest (2) |
stream_authentication | Values: username:password Default: Not defined |
This parameter establishes the username and password to use for the stream. The syntax is username:password |
stream_limit | Values: 0 - 2147483647 Default: 0 (unlimited) |
Limit the number of frames to number frames. After 'stream_limit' number of frames the connection will be closed by motion. The value 0 means unlimited., Limit the number of frames to number frames. After 'stream_limit' number of frames the connection will be closed by motion. The value 0 means unlimited. |
stream_localhost | Values: on, off Default: on |
Limits the access to the webcam to the localhost., Limits the access to the webcam to the localhost. |
stream_maxrate | Values: 1 - 100 Default: 1 |
Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited., Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited. |
stream_motion | Values: on, off Default: off |
If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by stream_maxrate. When 'off' the webcam stream always runs as defined by stream_maxrate., If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by stream_maxrate. When 'off' the webcam stream always runs as defined by stream_maxrate. |
stream_port | Values: 0 - 65535 Default: 0 (disabled) |
TCP port on which motion will listen for incoming connects with its webcam server., TCP port on which motion will listen for incoming connects with its webcam server. |
stream_preview_newline | Values: on, off Default: on |
If the webcontrol page has HTML enabled, Motion displays all of the streams on the home webcontrol page in HTML format so that all the images can be viewed by standard browsers. This parameter determines whether the image is placed on a new line in the webcontrol web page. , If the webcontrol page has HTML enabled, Motion displays all of the streams on the home webcontrol page in HTML format so that all the images can be viewed by standard browsers. This parameter determines whether the image is placed on a new line in the webcontrol web page. |
stream_preview_scale | Values: 1-65535 Default: 25 |
If the webcontrol page has HTML enabled, Motion displays all of the streams on the home webcontrol page in HTML format so that all the images can be viewed by standard browsers. This parameter indicates the percentage to scale the stream image when it is placed on the page. Numbers greater than 100 are permitted., If the webcontrol page has HTML enabled, Motion displays all of the streams on the home webcontrol page in HTML format so that all the images can be viewed by standard browsers. This parameter indicates the percentage to scale the stream image when it is placed on the page. Numbers greater than 100 are permitted. |
stream_quality | Values: 1 - 100 Default: 50 |
Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth., Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth. |
switchfilter | Values: on, off Default: 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., 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. |
target_dir | Values: Max 4095 characters Default: Not defined = current working directory |
The full path for the target directory for picture and movie files to be saved., The full path for the target directory for picture and movie files to be saved. |
text_changes | Values: on, off Default: off |
Turns the text showing changed pixels on/off., Turns the text showing changed pixels on/off. |
text_double | Values: on, off Default: off |
Draw characters at twice normal size on images., Draw characters at twice normal size on images. |
text_event | Values: Max 4095 characters Default: %Y%m%d%H%M%S |
This option defines the value of the speciel event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event., This option defines the value of the speciel event conversion specifier %C. You can use any conversion specifier in this option except %C. Date and time values are from the timestamp of the first image in the current event. |
text_left | Values: Max 4095 characters Default: Not defined |
User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %)., User defined text overlayed on each in the lower left corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %). |
text_right | Values: Max 4095 characters Default: %Y-%m-%d\n%T |
User defined text overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar 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 overlayed on each in the lower right corner. Use A-Z, a-z, 0-9, " / ( ) @ ~ # < > , . : - + _ \n and vertical bar and conversion specifiers (codes starting by a %). Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock |
thread | Values: Max 4095 characters Default: Not defined |
Specifies full path and filename for a thread config file. Each camera needs a thread config file containing the options that are unique to the camera. If you only have one camera you do not need thread config files. If you have two or more cameras you need one thread config file for each camera in addition to motion.conf. This option must be placed in motion.conf and not in a thread config file., Specifies full path and filename for a thread config file. Each camera needs a thread config file containing the options that are unique to the camera. If you only have one camera you do not need thread config files. If you have two or more cameras you need one thread config file for each camera in addition to motion.conf. This option must be placed in motion.conf and not in a thread config file. |
threshold | Values: 1 - 2147483647 Default: 1500 |
Threshold for declaring motion. The threshold is the number of changed pixels counted after noise filtering, masking, despeckle, and labelling., Threshold for declaring motion. The threshold is the number of changed pixels counted after noise filtering, masking, despeckle, and labelling. |
threshold_tune | Values: on, off Default: off |
Activates the automatic tuning of threshold level. ( It's broken ), Activates the automatic tuning of threshold level. ( It's broken ) |
timelapse_filename | Values: Max 4095 characters Default: %v-%Y%m%d-timelapse |
File path for timelapse mpegs relative to target_dir (ffmpeg only)., File path for timelapse mpegs relative to target_dir (ffmpeg only). |
track_auto | Values: on, off Default: off |
Enable auto tracking, Enable auto tracking |
track_iomojo_id | Values: 0 - 65535 Default: 0 |
Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller., Use this option if you have an iomojo smilecam connected to the serial port instead of a general stepper motor controller. |
track_maxx | Values: 0 - 65535 Default: 0 |
The maximum position for servo x., The maximum position for servo x. |
track_maxy | Values: 0 - 65535 Default: 0 |
The maximum position for servo y., The maximum position for servo y. |
track_motorx | Values: 0 - 65535 Default: 0 |
The motor number that is used for controlling the x-axis., The motor number that is used for controlling the x-axis. |
track_motory | Values: 0 - 65535 Default: 0 |
The motor number that is used for controlling the y-axis., The motor number that is used for controlling the y-axis. |
track_move_wait | Values: 0 - 65535 Default: 10 |
Delay during which tracking is disabled after auto tracking has moved the camera. Delay is defined as number of picture frames., Delay during which tracking is disabled after auto tracking has moved the camera. Delay is defined as number of picture frames. |
track_port | Values: Max 4095 characters Default: Not defined |
This is the device name of the serial port to which the stepper motor interface is connected., This is the device name of the serial port to which the stepper motor interface is connected. |
track_speed | Values: 0 - 255 Default: 255 |
Speed to set the motor to., Speed to set the motor to. |
track_step_angle_x | Values: 0-90 Default: 10 |
Angle in degrees the camera moves per step on the X-axis with auto tracking. Currently only used with pwc type cameras., Angle in degrees the camera moves per step on the X-axis with auto tracking. Currently only used with pwc type cameras. |
track_step_angle_y | Values: 0-40 Default: 10 |
Angle in degrees the camera moves per step on the Y-axis with auto tracking. Currently only used with pwc type cameras., Angle in degrees the camera moves per step on the Y-axis with auto tracking. Currently only used with pwc type cameras. |
track_stepsize | Values: 0 - 255 Default: 40 |
Number of steps to make., Number of steps to make. |
track_type | Values: 0 (none), 1 (stepper), 2 (iomojo), 3 (pwc), 4 (generic), 5 (uvcvideo) Default: 0 (None) |
Type of tracker., Type of tracker. |
tunerdevice | Values: Max 4095 characters Default: /dev/tuner0 |
The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD., The tuner device used for controlling the tuner in a tuner card. This option is only used when Motion is compiled for FreeBSD. |
v4l2_palette | Values: 0 - 17 Default: 17 |
The v4l2_palette allows the user to choose preferable palette to be use by Motion. Note that this is only the preferred option. If the video device does not support the requested format, Motion will loop through the available palettes to try to find one that is supported by both Motion and the device. Motion will report the supported palettes of the device when Motion starts when the log_level is specified as NTC or higher. The default of 17 is highly preferred since this the native format that Motion uses internally. , The v4l2_palette allows the user to choose preferable palette to be use by Motion. Note that this is only the preferred option. If the video device does not support the requested format, Motion will loop through the available palettes to try to find one that is supported by both Motion and the device. Motion will report the supported palettes of the device when Motion starts when the log_level is specified as NTC or higher. The default of 17 is highly preferred since this the native format that Motion uses internally. |
video_pipe | Values: Max 4095 characters Default: Not defined |
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., 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. |
videodevice | Values: Max 4095 characters Default: /dev/video0 (FreeBSD: /dev/bktr0) |
The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0., The video device to be used for capturing. Default for Linux is /dev/video0. for FreeBSD the default is /dev/bktr0. |
webcontrol_authentication | Values: Max 4096 characters Default: Not defined |
To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file., To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file. |
webcontrol_html_output | Values: on, off Default: on |
Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file., Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file. |
webcontrol_localhost | Values: on, off Default: on |
Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file., Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file. |
webcontrol_port | Values: 0 - 65535 Default: 0 (disabled) |
Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file., Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file. |
width | Values: Device Dependent Default: 352 |
The width in pixels of each frame. Valid range is camera dependent., The width in pixels of each frame. Valid range is camera dependent. |
Option | Range/Values Default |
Description |
---|---|---|
control_authentication | Values: Max 4096 characters Default: Not defined |
To protect HTTP Control by username and password, use this option for HTTP 1.1 Basic authentication. The string is specified as username:password. Do not specify this option for no authentication. This option must be placed in motion.conf and not in a thread config file. This option has been replaced by webcontrol_authentication |
control_html_output | Values: on, off Default: on |
Enable HTML in the answer sent back to a browser connecting to the control_port. This option must be placed in motion.conf and not in a thread config file. Note: This option has been renamed to webcontrol_html_output. |
control_localhost | Values: on, off Default: on |
Limits the http (html) control to the localhost. This option must be placed in motion.conf and not in a thread config file. This option has been replaced by webcontrol_localhost |
control_port | Values: 0 - 65535 Default: 0 (disabled) |
Sets the port number for the http (html using browser) based remote control. This option must be placed in motion.conf and not in a thread config file. This option has been replaced by webcontrol_port |
ffmpeg_cap_motion | Values: on, off Default: off |
Use ffmpeg libraries to encode motion type mpeg movies where you only see the pixels that changes. This option has been replaced by ffmpeg_output_debug_movies |
ffmpeg_cap_new | Values: on, off Default: off |
Use ffmpeg libraries to encode mpeg movies in realtime. This option is replaced by ffmpeg_output_movies |
ffmpeg_deinterlace | Values: on, off Default: off |
Use ffmpeg to deinterlace video. Necessary if you use an analog camera and see horizontal combing on moving objects in video or pictures. This option has been removed from Motion as it is no longer supported by ffmpeg or needed by ffmpeg |
ffmpeg_filename | Values: Max 4095 characters Default: %v-%Y%m%d%H%M%S |
File path for motion triggered ffmpeg movies (mpeg) relative to target_dir. This option was renamed to movie_filename in 3.2.5 to enable better integration of alternative movie libraries to the current ffmpeg solution. |
gap | Values: 0 - 2147483647 Default: 60 |
Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe. This option has been replaced by event_gap |
jpeg_filename | Values: Max 4095 characters Default: %v-%Y%m%d%H%M%S-%q |
File path for motion triggered images (jpeg or ppm) relative to target_dir. Value 'preview' makes a jpeg filename with the same name body as the associated saved mpeg movie file. This option has been replaced by picture_filename |
locate | Values: on, off, preview Default: off |
Locate and draw a box around the moving object. Value 'preview' makes Motion only draw a box on a saved preview jpeg image and not on the saved mpeg movie. This option has been replaced by locate_motion_mode |
low_cpu | Values: 0 - 100 Default: 0 (disabled) |
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. ( DEPRECATED ) |
max_mpeg_time | Values: 0 (infinite) - 2147483647 Default: 3600 |
The maximum length of an mpeg movie in seconds. Set this to zero for unlimited length. This option has been replaced by max_movie_time |
minimum_gap | Values: 0 - 2147483647 Default: 0 (no minimum) |
The minimum time between two shots in seconds. ( DEPRECATED ) |
mysql_db | Values: Max 4095 characters Default: Not defined |
Name of the MySQL database. |
mysql_host | Values: Max 4095 characters Default: localhost |
IP address or domain name for the MySQL server. Use "localhost" if motion and MySQL runs on the same server. |
mysql_password | Values: Max 4095 characters Default: Not defined |
The MySQL password. |
mysql_user | Values: Max 4095 characters Default: Not defined |
The MySQL user name. |
netcam_http | Values: 1.0, keep_alive, 1.1 Default: 1.0 |
The setting for keep-alive of network socket, should improve performance on compatible net cameras. This option has been replace by netcam_keepalive |
night_compensate | Values: on, off Default: 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 increase light sensitivity with their AGC (Automatic Gain Control) and this will increase noise. ( DEPRECATED ) |
output_all | Values: on, off Default: off |
Picture are saved continuously as if motion was detected all the time. |
output_motion | Values: on, off Default: off |
Output pictures with only the moving object. This feature generates the special motion type movies where you only see the pixels that changes as a graytone image. If labelling is enabled you see the largest area in blue. Smartmask is shown in red. This option has been replaced by output_debug_pictures |
output_normal | Values: on, off, first, best, center 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 like defined by output_motion. Default is that normal images are stored. This option has been replaced by output_pictures |
pgsql_db | Values: Max 4095 characters Default: Not defined |
Name of the PostgreSQL database. |
pgsql_host | Values: Max 4095 characters Default: localhost |
IP address or domain name for the PostgreSQL server. Use "localhost" if motion and PostgreSQL runs on the same server. |
pgsql_password | Values: Max 4095 characters Default: Not defined |
The PostgreSQL password. |
pgsql_port | Values: 0 - 65535 Default: 5432 |
The PostgreSQL server port number. This option has been replaced by database_port |
pgsql_user | Values: Max 4095 characters Default: Not defined |
The PostgreSQL user name. |
ppm | Values: on, off Default: off |
Output ppm images instead of jpeg. This uses less CPU time, but causes a LOT of hard disk I/O, and it is generally slower than jpeg. This option has been replaced by picture_type |
sql_log_image | Values: on, off Default: on |
Log to the database when creating motion triggered image file. This option has been replace by sql_log_picture |
sql_log_mpeg | Values: on, off Default: off |
Log to the database when creating motion triggered mpeg file. This option is replaced by sql_log_movie |
webcam_limit | Values: 0 - 2147483647 Default: 0 (unlimited) |
Limit the number of frames to number frames. After 'webcam_limit' number of frames the connection will be closed by motion. The value 0 means unlimited. This option has been replaced by stream_limit |
webcam_localhost | Values: on, off Default: on |
Limits the access to the webcam to the localhost. This option has been replaced by stream_localhost |
webcam_maxrate | Values: 1 - 100 Default: 1 |
Limit the framerate of the webcam in frames per second. Default is 1. Set the value to 100 for practically unlimited. This option has been replaced by stream_maxrate |
webcam_motion | Values: on, off Default: off |
If set to 'on' Motion sends slows down the webcam stream to 1 picture per second when no motion is detected. When motion is detected the stream runs as defined by webcam_maxrate. When 'off' the webcam stream always runs as defined by webcam_maxrate. This option has been replaced by stream_motion |
webcam_port | Values: 0 - 65535 Default: 0 (disabled) |
TCP port on which motion will listen for incoming connects with its webcam server. This option has been replaced by the stream_port option |
webcam_quality | Values: 1 - 100 Default: 50 |
Quality setting in percent for the mjpeg picture frames transferred over the webcam connection. Keep it low to restrict needed bandwidth. This option has been replaced by stream_quality |
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 |
---|---|---|
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. |
/var/log/messages
(e.g. RedHat/Fedora) or /var/log/syslog
and /var/log/user.log
(e.g. Debian).
cd /usr/local/ffmpeg ./configure --enable-shared make make installThis creates the
libavcodec.so
and libavformat.so
libraries 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' privileges 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 libraries for ffmpeg (libavcodec.so
and libavformat.so
) 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
.
There are various RPMs available from different repositories. Some need additional RPMs that are actually not needed by Motion but need to be installed to satisfy dependencies. The editor has tried different RPMs of ffmpeg-0.4.8 and they all seem to work.
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.)
Note that if you install ffmpeg from source and already have ffmpeg installed from an RPM, the Motion configure may very well find the binary library from the rpm instead of the sources. Make sure to uninstall any old ffmpeg RPMs before you install ffmpeg from sources.
These are the config file options related to ffmpeg.
This feature uses ffmpegs libavcodec to encode a timelapse 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 have no impact on the ffmpeg timelapse function.
Note that the timelapse format is always mpeg1 independent of ffmpeg_video_codec. This is because mpeg1 allows the timelapse to stop and the file to be reopened and more film appended.
To use this feature you need to install the FFmpeg Streaming Multimedia System.
(renamed from ffmpeg_timelaps to ffmpeg_timelapse in 3.1.14)
Supported formats are:
|
text_event
feature is special in that it defines the conversion specifier %C which can be used both for text display and for filenames.
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.
Note that the options snapshot_filename
, jpeg_filename
, ffmpeg_filename
, and timelapse_filename
all allow specifying directories by using '/' in the filename. 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. And note that targer_dir
does not allow conversion specifiers.
The conversion specifier %C which is defined by the option text_event is interesting in connection with filenames because it can be used to create files and directories for each event in a very flexible way.
The convertion specifier %t (thread/camera number) is also very useful. Here is an example of filename definitions in motion.conf:
target_dir /usr/local/webcam snapshot_filename cam%t/%v-%Y%m%d%H%M%S-snapshot jpeg_filename cam%t/%v-%Y%m%d%H%M%S-%q ffmpeg_filename cam%t/%v-%Y%m%d%H%M%S timelapse_filename cam%t/%Y%m%d%H-timelapseThe smart thing is that this defines the filename of all your camera threads in motion.conf so you do not need to specify target dir and filenames in the thread config files. In the above example an mpegfile for camera thread 3 will be saved as a filename similar to
/usr/local/webcam/cam3/28-20051128130840.avi
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.
Security Warning! Note that the flexibility of this feature also means you have to pay attention to the following. text_event
, text_left
, text_right
, sql_query
, snapshot_filename
, jpeg_filename
, ffmpeg_filename
, timelapse_filename
, on_event_start
, on_event_end
, on_picture_save
, on_movie_start
, on_movie_end
, and on_motion_detected
.
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. |
%C | Text defined by the text_event feature |
%d | The day of the month as a decimal number (range 01 to 31). |
%D | Number of pixels detected as Motion. If labelling is enabled the number is the number of pixels in the largest labelled motion area. |
%E | Modifier: use alternative format, see below. |
%f | File name - used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features. |
%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 | Width of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). |
%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). |
%J | Height of the rectangle containing the motion pixels (the rectangle that is shown on the image when locate is on). |
%k | The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.) |
%K | X coordinate in pixels of the center point of motion. Origin is upper left corner. |
%l | The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.) |
%L | Y coordinate in pixels of the center point of motion. Origin is upper left corner and number is positive moving downwards (I may change this soon). |
%m | The month as a decimal number (range 01 to 12). |
%M | The minute as a decimal number (range 00 to 59). |
%n | Filetype as used in the on_picture_save, on_movie_start, on_movie_end, and sql_query features. |
%N | Noise level. |
%o | Threshold. The number of detected pixels required to trigger motion. When threshold_tune is 'on' this can be used to show the current tuned value of threshold. |
%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. |
%Q | Number of detected labels found by the despeckle feature |
%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 | Thread number (camera number) |
%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. |
ppm
is set to off.
The webcam_maxrate
and webcam_quality
options are important to limit the load on your server and link. Don't set them too high unless you only use it on the localhost or on an internal LAN. The option webcam_quality
is equivalent to the quality level for jpeg pictures.
The webcam_limit
option prevents people from loading your Network connection by streaming for hours and hours. The options defines the number of picture frames sent as mjpeg Motion will allow without re-connecting (e.g. clicking refresh in the browser).
The option webcam_localhost
is a security feature. When enabled you can only access the webserver on the same machine as Motion is running on. If you want to present a live webcam on your web site this feature must be disabled.
The webserver generates a stream in "multipart jpeg" format (mjpeg). You cannot watch the stream with most browsers. Only certain versions of Netscape works. Mozilla and Firefox brosers can view the mjpeg stream but you often have to refresh the page once to get the streaming going. Internet Explorer cannot show the mjpeg stream. For public viewing this is not very useful. There exists a java applet called Cambozola which enabled any Java capable browser to show the stream. To enable the feature to a broad audience you should use this applet or similar.
To use the webcam feature with Cambozola is actually very simple.
1. Create a html page in which you will want the streamed picture.
2. In the html page include this code
<applet code=com.charliemouse.cambozola.Viewer archive=cambozola.jar width="320" height="240" style="border-width:1; border-color:gray; border-style:solid;"> <param name=url value="http://www.myurl.com:8081"> </applet>Where the width and height is the image size of the video stream. Replace www.myurl.com:8081 by the real url and port number of your choice. 3. In the same directory you place the cambozola.jar file. No need to build the java applet from source. Simply use the applet in the package. 4. Enable the feature in motion.conf. You can also view the live webcam stream using MPlayer like this:
mplayer -demuxer lavf http://www.myurl.com:8081/stream.mjpgNote that the
stream.mjpg
part is important, without it you will get a LAVF_check: no clue about this gibberish!
error from libavformat.
Note that you can stream from multiple videos by having several applet viewers on each page (pointed to different url's, of course).
These are the special webcam parameters.
0 9 * * * root /usr/bin/lwp-request http://localhost:8080/0/detection/start > /dev/null 0 18 * * * root /usr/bin/lwp-request http://localhost:8080/0/detection/pause > /dev/nullIf you want to use the http remote control from your own software (for example your own PHP front end) you can set the new motion.conf option html_output off. Then Motion answers back with very basic text only and no html around it. A bit like the xmlrpc interface did. To remote control Motion from a web pages you can for example use PHP. In PHP it takes this simple code line to send a remote commend to Motion. Here we pause motion detection for camera 2
readfile('http://localhost:8080/2/detection/pause');
What happened to XMLRPC?
XMLRPC is replaced by a simpler http remote control interface. It is still being worked on but it is absolutely useable now and much nicer to work with than xmlrpc. Another advantage is that you do not need to install xmlrpc libraries. It is all written in standard C.
Security Warning! Note that this feature also means you have to pay attention to the following. quiet
is also included in this section.
A redesign of the external commands was due. They were not very easy to understand, not all were flexible enough and some were missing. So a new external command feature set was made for 3.2.1 and on.
This is how the new script commands look like:
Function | Old Option | New Option | Argument Appended |
---|---|---|---|
Start of event (first motion) | execute | on_event_start | None |
End of event (no motion for gap seconds) | New! | on_event_end | None |
Picture saved (jpg or ppm) | onsave | on_picture_save | Filename of picture |
Movie starts (mpeg file opened) | onmpeg | on_movie_start | Filename of movie |
Movie ends (mpeg file closed) | onffmpegclose | on_movie_end | Filename of movie |
Motion detected (each single frame with Motion detected) | New! | on_motion_detected | None |
#!/bin/sh # Motion sample script to send an e-mail at start of an event. # Replaces the former 'mail' option. # Just define this script as 'on_event_start'-script in motion.conf like that: # on_event_start send_mail "%Y-%m-%d %T" #change to suit your needs: #location of 'mail' binary MAIL="/usr/bin/mail" #Destination e-mail address TO="root@localhost" #Subject of the e-mail SUBJECT="Motion detected" #Don't change anything below this line echo -e "This is an automated message generated by motion.\n\nMotion detected: $1\n\n" | $MAIL -s "$SUBJECT" $TO
#/usr/local/bin/send_mail $1
you can combine both sending email and sms.
#!/bin/sh # Motion sample script to send an sms at start of an event. # Replaces the former 'sms' option. # Just define this script as 'on_event_start'-script in motion.conf like that: # on_event_start send_sms "%Y-%m-%d %T" # # If you want to send an e-mail message here as well, just uncomment the last # line of this script. #change to suit your needs: #location of 'sms-client' binary SMS_CLIENT="/usr/bin/sms_client" #Destination sms number TO="12345" #Don't change anything below this line $SMS_CLIENT $TO "Motion detected $1" #/usr/local/bin/send_mail $1
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 |
CREATE TABLE security (camera int, filename char(80) not null, frame int, file_type int, time_stamp timestamp(14), text_event timestamp(14));
If you choose to use text_event for a non-timestamp value you can instead define something like.
CREATE TABLE security (camera int, filename char(80) not null, frame int, file_type int, time_stamp timestamp(14), text_event char(40));
Remember to update grant table to give access to the mysql username you choose for motion.
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.
The options for MySQL
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 11Note 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. Download the latest video4linux loopback device . Place the file in a place of your own choice. Untar and uncompress the file to the place you want the program installed. Editor recommends /usr/local/vloopback.
cd /usr/local
tar -xvzf /path/to/vloopback-1.1-rc1.tar.gz
You now have a directory called vloopback-1.1-rc1. You can rename it to vloopback (mv vloopback-1.1-rc1 vloopback). I recommend creating a symbolic link to the current version. This way you can more easily experiment with different versions simply by changing the link.
ln -s vloopback-1.1-rc1 vloopback
Now change to the new directory
cd vloopback
Build the code
make
There is a good chance that the make will not work and give you a long list of errors. To run make the following must be available on you machine. ln -s /usr/src/linux-2.4.18-4 /usr/src/linux
#include <linux/malloc.h>
with the line
#include <linux/slab.h>
Install the code you built as a Kernel module. There are two options: pipes should be set to the number of video loopbacks that you want. Probably one for each camera. The dev_offset defines which video device number will be the first. If dev_offset is not defined the vloopback module will install itself from the first available video device. If you want the cameras to be assigned to the lower video device numbers you must either load vloopback after loading the video device modules OR use the dev_offset option when loading vloopback. Vloopback then installs itself in the sequence input 0, output 0, input 1, output 1, input 2, output 2 etc. Here is shown the command for our example of 4 cameras and 4 loopback devices and the first loopback device offset to /dev/video4.
/sbin/insmod /usr/local/vloopback/vloopback.o pipes=4 dev_offset=4
When you run the command you may get a warning about tainting the Kernel. Just ignore this.
You can choose to copy the vloopback.o file into a directory in the /lib/modules tree where the insmod/modprobe programs are already looking for modules. Then the command gets simpler (/sbin/insmod vloopback pipes=.....).
If you want the loopback device to load during boot, you can place the call in one of the bootup scripts such as /etc/rc.d/rc.local. Vloopback should be loaded before you start motion.
To activate the vloopback device in motion set the 'video_pipe' option in the motion.conf file. You can also view the special motion pictures where you see the changed pixels by setting the option 'motion_video_pipe' in motion.conf. When setting the video_pipe and/or motion_video_pipe options either specify the input device as e.g. /dev/video4. You can also set the parameter to '-' which means that motion will find the first vacant video loopback device input. If you have more than one camera you may want to control which loopback device each thread uses. Then you need to define the specific device name in motion.conf for the first camera and in each thread config file for the other cameras. If you set the video_pipe parameter to '-' in the motion.conf file and not setting it in the thread config files, motion automatically assign video devices in the same sequence as the threads are loaded. You can combine both video_pipe and motion_video_pipe but then naturally you will need twice as many pipes.
De-activating should be done with this command
/sbin/modprobe -r vloopback
Description of the motion.conf options related to video loopback device.
-- KennethLavrsen - 13 Apr 2005