【翻译】动态图像监测开源代码 motion 学习-----Motion Guide - Getting It Running(让motion动起来)
说在前面:
原文连接 点击打开链接
Motion Guide - Getting It Running(让motion动起来)
This topic consists of the following subtopics:RunningMotionConfigFiles, CommandLineOptions,ConfigFileOptions, SignalsKill, ErrorLogging.
Running Motion(运行motion)
Important Definitions
Motion is invoked from the command line. It has no GUI. (motion用命令行调用,不支持图形用户界面)。Everything is controlled from config files. (用配置文件进行所有控制)。From version 3.2 the command line is only used to define location of config file and a few special runtime modes (setup and non-daemon).
A few important definitions.
- A snapshot is a picture taken at regular intervals independently of any movement in the picture.
- A "motion" image/mpeg shows the pixels that have actually changed during the last frames. These pictures are not very useful for normal presentation to the public but they are quite useful for testing and tuning and making mask files as you can see exactly where motion sees something moving. Motion is shown in greytones. If labelling is enabled the largest area is marked as blue. Smart mask is shown in red.
- A "normal" image is the real image taken by the camera with text overlayed.
The Config Files(配置文件)
If Motion was invoked with command line option
-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:
- Current directory from where motion was invoked
- Then in a directory called '.motion' in the current users home directory (shell environment variable $HOME). E.g. /home/goofy/.motion/motion.conf
- The directory defined by the --sysconfdir=DIR when running .configure during installation of Motion
(If this option was not defined the default is /usr/local/etc/)
Motion has a configuration file in the distribution package called motion-dist.conf. When you run 'make install' this file 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.(把motion-dist.conf 重命名为motion.conf)
It is often seen that people copy the entire motion.conf into the thread config files and change a few options. This works but it not recommended because it is more difficult to maintain and overview. Keep all the common options in motion.conf and the few unique only in the thread config files.(不推荐这段话里面的线程配置文件实现方式)
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.
To make it clear, the thread files format and syntax is the same as motion.conf. An example of what you might want in a thread file as follows: assume you have two cameras, attached to one system. Create files thread0.conf and thread1.conf. At the end of motion.conf, uncomment out the lines that refer to them. The full contents of the thread files can be as simple as(两个摄像头时,其线程配置文件内容简单示例如下)
thread0.conf:
videodevice /dev/video0
stream_port 8081
thread1.conf:
videodevice /dev/video1
stream_port 8082
- Motion reads the configuration file motion.conf from the beginning of the file going down line by line.
- If the option "thread" is defined in motion.conf, the thread configuration file(s) is/(are) read.
- Motion continues reading the rest of the motion.conf file. Any options from here will overrule the same option previously defines in a thread config file.
- Motion reads the command line option again overruling any previously defined options.
Nearly all config options can be unique for a specific camera and placed in a thread config file. There are a few options that must be in motion.conf and cannot be in a thread config file: control_authentication,control_html_output, control_localhost, control_port,daemon, and thread.(必须定义在配置文件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.(如果建立motion时没有用到ffmpeg, mysql 等功能特性,motion将自动忽略这些特性选项。不必手动删除或者把它们注释掉。)
If you run the http control commandhttp://host:port/0/config/writeyes, 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.(当重建motion或者进行了版本升级,可以运行motion.conf.write 命令,用之前的配置文件配置新的配置文件,而新配置文件中的新特性则采用默认值。这使得升级变得很容易。)
Command Line Options(命令行选项)
![ALERT! ALERT!](http://www.lavrsen.dk/foswiki/pub/System/DocumentGraphics/warning.png)
SYNOPSIS
motion [ -hns ] [ -c config file path ] [ -d level ] [ -p process_id_file ]
具体选项见 点击打开链接
Config File Options(配置文件选项)
These are the options that can be used in the config file.
All number values are integer numbers (no decimals allowed). Boolean options can be on or off.(所有的数字均为整数,不允许小数。布尔选项可以是on或者off)
Some configuration options are only used if Motion is built on a system that has the matching software libraries installed (MySQL, PostgreSQL and FFMPEG).(有些配置是专门用在匹配的软件上的,具体可看链接 点击打开链接)
EDIT:
Lots of config options have changed! In the latest source, most of the below ffmpeg options don't work, along with a few other options. By default a source install will put a config file with correct options in /usr/local/etc/motion-dist.conf. You can also try looking in motion-dist.conf.in in the source directory. The config options listed below will still work for older versions of motion, such as the debian package, but will not work with the latest source.
Linked below is a motion config file which works with the current motion source as of 23 Apr 2014.
Options in Alphabetical Order.(选项按字母表排序)
The table below lists all the Motion options in alphabetical order. Click on the option name to see a longer description of each.
具体见链接点击打开链接 往下翻就能找到
Signals (sent with e.g. kill command)(信号)
kill -s SIGHUP pid
, where the last parameter is the process ID which you get by typingps -ef ¦ grep motion
. The PID is the first on the list which is the parent process for the threads.(向进程发送信号,获得进程信号,这是daemon为on) 。
Motion responds to the following signals:(motion接收到对应信号后的动作是 点击打开链接 )
Error Logging(错误日志)
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
(e.g. RedHat/Fedora) or/var/log/syslog
and /var/log/user.log
(e.g. Debian).
-- KennethLavrsen - 13 Apr 2005