Motion has a very advanced and flexible automated filenaming feature.
By using conversion specifiers
(codes that consist of a '%' followed by a letter) you can build up the filenames including sub directories for pictures and movies using any combination of letters, numbers and conversion specifiers which are codes that represents time, date, event number and frame numbers.
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
all allow specifying directories by using '/' in the filename. These will all be relative to
. This means in principle that you can specify
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
as deep or detailed as possible for this reason. And note that
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:
The 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
NOTE: Unless you use the
option to limit the number of shots to less then one per second - you must use the frame modifier %q as part of the
. Otherwise the pictures saved within the same second will overwrite each other. The %q in
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.
These are the advanced filename options in motion.conf
- Anyone with access to the remote control port (http) can alter the values of these options and save files anywhere on your server with the same privileges as the user running Motion. Anyone can access your control port if you have not either limited access to localhost or limited access using firewalls in the server. You should always have a router between a machine running Motion with remote control enabled and the Internet and make sure the Motion control port is not accessible from the outside.
- Anyone with local access to the computer and edit rights to the motion.conf file can alter the values of these options and save files anywhere on your server with the same privileges as the user running Motion. Make sure the motion.conf file is maximum readonly to anyone else but the user running Motion.
- It is a good idea to run Motion as a harmless user. Not as root.
- 12 Dec 2005