Main Documentation

From ZoneMinder

Jump to: navigation, search

Please Note: This documentation is not yet fully updated for changes in versions from 1.23.0 or 1.24. Updates will be applied as soon as possible.



Contents

Introduction

Welcome to ZoneMinder, the all-in-one Linux GPL'd security camera solution.

A while back my garage was burgled and all my power tools were stolen! I realized shortly after that if I'd just had a camera overlooking the door then at least I'd have know exactly when and who did the dirty deed. And so ZoneMinder was born. It's still relatively new but hopefully it has developed into something that can be genuinely useful and prevent similar incidents or even perhaps bring some perpetrators to justice.

PROPOSED ADDITION Most commercial "security systems" are designed as a monitoring system that also records. Recording quality can vary from bad to unusable, locating the relevant video can range from challenging to impractical, and exporting can often only be done with the manual present. ZoneMinder was designed primarily to record, and allow easy searches and exporting. Recordings are of the best possible quality, easy to filter and find, and simple to export using any system with a web browser. It also monitors.

ZoneMinder is designed around a series of independent components that only function when necessary limiting any wasted resource and maximising the efficiency of your machine. A fairly ancient Pentium II PC should be able to track one camera per device at up to 25 frames per second with this dropping by half approximately for each additional camera on the same device. Additional cameras on other devices do not interact so can maintain this frame rate. Even monitoring several cameras still will not overload the CPU as frame processing is designed to synchronise with capture and not stall it.

As well as being fast ZoneMinder is designed to be friendly and even more than that, actually useful. As well as the fast video interface core it also comes with a user friendly and comprehensive PHP based web interface allowing you to control and monitor your cameras from home, at work, on the road, or even a web enabled cell phone. It supports variable web capabilities based on available bandwidth. The web interface also allows you to view events that your cameras have captured and archive them or review them time and again, or delete the ones you no longer wish to keep. The web pages directly interact with the core daemons ensuring full co-operation at all times. ZoneMinder can even be installed as a system service ensuring it is right there if your computer has to reboot for any reason.

The core of ZoneMinder is the capture and analysis of images and there is a highly configurable set of parameters that allow you to ensure that you can eliminate false positives whilst ensuring that anything you don't want to miss will be captured and saved. ZoneMinder allows you to define a set of 'zones' for each camera of varying sensitivity and functionality. This allows you to eliminate regions that you don't wish to track or define areas that will alarm if various thresholds are exceeded in conjunction with other zones.

ZoneMinder is fresh off the keyboard and so comes with no warranty whatsoever, please try it, send your feedback and if you get anything useful out of it let me know.

ZoneMinder is free but if you do get ZoneMinder up and running and find it useful then please feel free to visit http://www.zoneminder.com/donate.html where any donations will be appreciated and will help to fund future improvements to ZoneMinder. This would be especially relevant if you use ZoneMinder as part of your business, or to protect your property.

Requirements

ZoneMinder needs a couple of things to work. If you are installing a package (Debian, Ubuntu, or RedHat) the package should install all of the needed core components. However, you may want to install several optional components (such as ffmpeg) as well. If you are installing from a LiveCD, it will install all of the needed components, but they may not be the latest version. If you compile it from source, ordinarily the ‘configure’ script will check for the presence of required (and optional) components but it is useful to be prepared beforehand.

Firstly, it uses MySQL so you'll need that. In order to compile you need to make sure you have a development installation and not just a runtime; this is because it needs to use the MySQL header files. If you are running an RPM based distribution then it’s probably worth installing all the pure MySQL rpm files to be sure you have the right ones. If you are installing the .deb file, it will install it for you. If you already have a MySQL install, be aware that changes you have made to security or configuration may cause problems.

Next it does things with JPEGs so you'll need at least libjpeg.a which I think come as standard nowadays with most distributions. Users have reported varying degrees of success with other jpeg libraries such as jpeg-mmx but these are not officially supported. If you plan to use network cameras then the Perl Compatible Regular Expression library (libpcre.a) can prove useful but is not always essential. ZoneMinder also uses the netpbm utilities in a very limited way to generate thumbnails under certain circumstances though this can be modified.

ZoneMinder can generate MPEG videos if necessary, for this you'll need either ffmpeg (recommended) or the Berkeley MPEG encoder (mpeg_encode). If you don't have either, don't worry, as the options will be hidden and you'll not really miss too much. Some of the authentication uses openssl MD5 functions, if you get a grumble about these during configuration all it will mean is that authentication won’t be used for streaming. The web interface uses PHP and so you need that in your apache or other web server as well, make sure MySQL support is available either statically or as a module. There are also various perl modules that you may need that vary depending on which options you choose on installation, for more details see later in this document.

Finally, there is quite a bit of image streaming in the package. So if you don't have FireFox or another browser that supports image streaming natively I recommend you get the excellent Cambozola java applet from http://www.charliemouse.com:8080/code/cambozola/ which will let you view the image stream in Internet Explorer and others. Otherwise you're limited to just refreshing still images or mpeg based streams, if you have compatible plugins. As upgraded version have occasionally caused problems, a known working version of Cambozola is also in the Downloads section of the ZoneMinder website.

Hardware-wise, ZoneMinder has been used with various video and USB cameras with the V4L interface. It will also work with most Network or IP cameras. I don't have a lot of cameras myself so I've not had chance to test it with a huge range personally. However, there are many other people who have used many other products, and there is a list of devices that are definitely known to work on the web site. Please enter you camera on the Wiki list on zoneminder.com if your camera works and is not listed. You do need to have Video4Linux installed. In terms of computer hardware, there are no hard and fast requirements. You may get a system that works with one or two cameras going on an old P200 but you will be able to support more cameras, at a higher frame rate, with faster machines with more RAM. More guidance is available on the web forums.

Components

ZoneMinder is not a single monolithic application but is formed from several components. These components primarily include executable compiled binaries which do the main video processing work, perl scripts which usually perform helper and/or external interface tasks and php web scripts which are used for the web interface.

A brief description of each of the principle components follows.

zmc 
This is the ZoneMinder Capture daemon. This binary's job is to sit on a video device and suck frames off it as fast as possible, this should run at more or less constant speed.
zma 
This is the ZoneMinder Analysis daemon. This is the component that goes through the captured frames and checks them for motion which might generate an alarm or event. It generally keeps up with the Capture daemon but if very busy may skip some frames to prevent it falling behind.
zmf 
This is the ZoneMinder Frame daemon. This is an optional daemon that can run in concert with the Analysis daemon and whose function it is to actually write captured frames to disk. This frees up the Analysis daemon to do more analysis (!) and so keep up with the Capture daemon better. If it isn’t running or dies then the Analysis daemon just writes them itself.
zms 
This is the ZoneMinder Streaming server. The web interface connects with this to get real-time or historical streamed images. It runs only when a live monitor stream or event stream is actually being viewed and dies when the event finishes or the associate web page is closed. If you find you have several zms processes running when nothing is being viewed then it is likely you need a patch for apache (see the Troubleshooting section). A non-parsed header version of zms, called nph-zms, is also installed and may be used instead depending on your web server configuration.
zmu 
This is the ZoneMinder Utility. It's basically a handy command line interface to several useful functions. It’s not really meant to be used by anyone except the web page (there's only limited 'help' in it so far) but can be if necessary, especially for debugging video problems.
zmfix 
This is a small binary that exists only to ensure that the video device files can be read by the main capture daemons. It is often the case that these device files are set to be accessible by root only on boot. This binary runs setuid and ensures that they have appropriate permissions. This is not a daemon and runs only on system start and then exits. Note that ZoneMinder 1.26.5 was the last release with this utility. Running zmfix setuid was a security risk is no longer needed because most modern Linux distros assign local devices to the "video" group. Simply assign the account the capture daemons run under (usually apache or www-data) to the video group.

As well as this there are the web PHP files in the web directory and some perl scripts in the scripts directory. These scripts all have some configuration at the top of the files which should be viewed and amended if necessary and are as follows.

zmpkg.pl 
This is the ZoneMinder Package Control script. This is used by the web interface and service scripts to control the execution of the system as a whole.
zmdc.pl 
This is the ZoneMinder Daemon Control script. This is used by the web interface and the zmpkg.pl script to control and maintain the execution of the capture and analysis daemons, amongst others. You should not need to run this script yourself.
zmfilter.pl 
This script controls the execution of saved filters and will be started and stopped by the web interface based on whether there are filters that have been defined to be autonomous. This script is also responsible for the automatic uploading of events to a 3rd party server.
zmaudit.pl 
This script is used to check the consistency of the event file system and database. It can delete orphaned events, i.e. ones that appear in one location and not the other as well as checking that all the various event related tables are in line. It can be run interactively or in batch mode either from the command line or a cron job or similar. In the zmconfig.pl there is an option to specify fast event deletes where the web interface only deletes the event entry from the database itself. If this is set then it is this script that tidies up the rest.
zmwatch.pl 
This is a simple script purely designed to keep an eye on the capture daemons and restart them if they lockup. It has been known for sync problems in the video drivers to cause this so this script makes sure that nothing important gets missed.
zmupdate.pl 
Currently this script is responsible for checking whether a new version of ZoneMinder is available and other miscellaneous actions related to upgrades and migrations. It is also intended to be a ‘one stop shop’ for any upgrades and will execute everything necessary to update your installation to a new version.
zmvideo.pl 
This script is used from the web interface to generate video files in various formats in a common way. You can also use it from the command line in certain circumstances but this is not usually necessary.
zmx10.pl 
This is an optional script that can be used to initiate and monitor X10 Home Automation style events and interface with an alarm system either by the generation of X10 signals on ZoneMinder events or by initiating ZoneMinder monitoring and capture on receipt of X10 signals from elsewhere, for instance the triggering of an X10 PIR. For example I have several cameras that don’t do motion detection until I arm my alarm system whereupon they switch to active mode when an X10 signal is generated by the alarm system and received by ZoneMinder.
zmtrigger.pl 
This is an optional script that is a more generic solution to external triggering of alarms. It can handle external connections via either internet socket, unix socket or file/device interfaces. You can either use it ‘as is’ if you can interface with the existing format, or override connections and channels to customise it to your needs. The format of triggers used by zmtrigger.pl is as follows "<id>|<action>|<score>|<cause>|<text>|<showtext>" where
  • 'id' is the id number or name of the ZM monitor
  • 'action' is 'on', 'off', 'cancel' or ‘show’ where 'on' forces an alarm condition on, 'off' forces an alarm condition off and 'cancel' negates the previous 'on' or 'off'. The ‘show’ action merely updates some auxiliary text which can optionally be displayed in the images captured by the monitor. Ordinarily you would use 'on' and 'cancel', 'off' would tend to be used to suppress motion based events. Additionally 'on' and 'off' can take an additional time offset, e.g. on+20 which automatically 'cancel's the previous action after that number of seconds.
  • 'score' is the score given to the alarm, usually to indicate it's importance. For 'on' triggers it should be non-zero, otherwise it should be zero.
  • 'cause' is a 32 char max string indicating the reason for, or source of the alarm e.g. 'Relay 1 open'. This is saved in the ‘Cause’ field of the event. Ignored for 'off' or 'cancel' messages
  • 'text' is a 256 char max additional info field, which is saved in the ‘Description’ field of an event. Ignored for 'off' or 'cancel' messages.
  • 'showtext' is up to 32 characters of text that can be displayed in the timestamp that is added to images. The ‘show’ action is designed to update this text without affecting alarms but the text is updated, if present, for any of the actions. This is designed to allow external input to appear on the images captured, for instance temperature or personnel identity etc.
Note that multiple messages can be sent at once and should be LF or CRLF delimited. This script is not necessarily intended to be a solution in itself, but is intended to be used as ‘glue’ to help ZoneMinder interface with other systems. It will almost certainly require some customisation before you can make any use of it. If all you want to do is generate alarms from external sources then using the ZoneMinder::SharedMem perl module is likely to be easier.
zmcamtool.pl 
This optional script is new for the upcoming 1.27 release of ZoneMinder. It is intended to make it easy to do the following: bring in new ptz controls and camera presets, convert existing monitors into presets, and export custom ptz controls and presets. For the initial release, this script is not integrated into the UI and must be called from the command line. Type zmcamtool.pl --help from the command line to get an explanation of the different arguments one can pass to the script.
zmcontrol-*.pl 
These are a set of example scripts which can be used to control Pan/Tilt/Zoom class cameras. Each script converts a set of standard parameters used for camera control into the actual protocol commands sent to the camera. If you are using a camera control protocol that is not in the shipped list then you will have to create a similar script though it can be created entirely separately from ZoneMinder and does not need to named as these scripts are. Although the scripts are used to action commands originated from the web interface they can also be used directly or from other programs or scripts, for instance to implement periodic scanning to different presets.
zmtrack.pl 
This script is used to manage the experimental motion tracking feature. It is responsible for detecting that an alarm is taking place and moving the camera to point to the alarmed location, and then subsequently returning it to a defined standby location. As well as moving the camera it also controls when motion detection is suspended and restored so that the action of the camera tracking does not trigger endless further alarms which are not justified.
zm 
This is the (optional) ZoneMinder init script, see below for details.

Finally, there are also a number of ZoneMinder perl modules included. These are used by the scripts above, but can also be used by your own or 3rd party scripts. Full documentation for most modules is available in ‘pod’ form via ‘perldoc’ but the general purpose of each module is as follows.

ZoneMinder.pm 
This is a general ZoneMinder container module. It includes the Base.pm, Config.pm Debug.pm, Database.pm, and SharedMem.pm modules described below. It also exports all of their symbols by default. If you use the other modules directly you have request which symbol tags to import.
ZoneMinder/Base.pm 
This is the base ZoneMinder perl module. It contains only simple data such as version information. It is included by all other ZoneMinder perl modules
ZoneMinder/Config.pm 
This module imports the ZoneMinder configuration from the database.
ZoneMinder/Debug. pm 
This module contains the defined Debug and Error functions etc, that are used by scripts to produce diagnostic information in a standard format.
ZoneMinder/Database.pm 
This module contains database access definitions and functions. Currently not a lot is in this module but it is included as a placeholder for future development.
ZoneMinder/SharedMem.pm 
This module contains standard shared memory access functions. These can be used to access the current state of monitors etc as well as issuing commands to the monitors to switch things on and off. This module effectively provides a ZoneMinder API.
ZoneMinder/ConfigAdmin.pm 
This module is a specialised module that contains the definition, and other information, about the various configuration options. It is not intended for use by 3rd parties.
ZoneMinder/Trigger/*.pm 
These modules contain definitions of trigger channels and connections used by the zmtrigger.pl script. Although they can be used ‘as is’, they are really intended as examples that can be customised or specialised for different interfaces. Contributed modules for new channels or connections will be welcomed and included in future versions of ZoneMinder.

Building

To build ZoneMinder the first thing you need to do is run the included configure script to define some initial configuration. If you are happy with the default settings for the database host (‘localhost’), name (‘zm’), user (‘zmuser’) and password (‘zmpass’) then you can just type

./configure --with-webdir=<your web directory> --with-cgidir=<your cgi directory>

where --with-webdir is the directory to which you want to install the PHP files, and --with-cgidir is the directory to which you want to install CGI files. These directories could be /var/www/html/zm and /var/www/cgi-bin for example.

If you want to override any of the default database values then you can append them to the configure command, for example to use a database password of ‘zmnewpass’ do

./configure --with-webdir=<your web directory> --with-cgidir=<your cgi directory> ZM_DB_PASS=zmnewpass

and so on. The values you can use are ZM_DB_HOST, ZM_DB_NAME, ZM_DB_USER and ZM_DB_PASS. Other than the database name, which is substituted into the database creation script, these values can easily be changed after this step.

If the script cannot find your MySQL installation, for instance if it is installed in an unusual location, then --with-mysql identifies the root directory where you have installed it, usually /usr.

If you want to use real MPEG based streaming you will need to have built and installed the ffmpeg tools. You can then also use --with-ffmpeg=<path to ffmpeg root> to help configure find it if it’s not installed in a default location. Note, you have to make sure you have installed the ffmpeg headers and libraries (make installlib) as well as the binaries (make install), or a development package with them in.

If you have built ffmpeg with any additional options which require extra libraries in the link stage then you can use --with-extralibs to pass these libraries to the configure script, to prevent unresolved dependencies. Otherwise ignore this option.

If you are on a 64 bit system you may find that the --with-libarch option helps you correctly define your library paths.

There are also two further parameters you can add if your web user and group are not both 'apache'. These are --with-webuser and --with-webgroup which you would normally change to be your system httpd daemon owner. Alternatively you should be able to create a 'zoneminder' system user, assign that user to your httpd daemon group and then use use 'zoneminder' as the webuser instead of apache or whatever your system uses. This has the additional benefit of partitioning security somewhat and not opening up full access to all web user files in the event of a security breach.

This is also when you have the opportunity to pass any additional flags to the compiler to modify how the application is built. To do this append CFLAGS="<options>" and CXXFLAGS="<options>" to pass in compiler flags for 'c' and 'c++' compilation respectively. For instance the default compiler flags are usually --O2 and --g to create binaries with moderate optimisation and debugging symbols. If you wanted to optimise further, including processor specific tweaks but still keep debugging symbols then could use CFLAGS="-g -O3 -march=pentium4" and CXXFLAGS="-g -O3 -march=pentium4" for instance. Consult the gcc/g++ documentation for help on these and other options. Also be aware that even if you optimise your ZoneMinder build, any libraries that get linked in will only perform as well as the options used when they were built allows. Thus to get full benefit you would usually need to rebuild libjpeg.a and/or other libraries with similar options.

Type

./configure --help

for details on these, and other, options.

Now you can just type make to do the build. The first time you run this you may get a warning about a Makefile being rebuilt in the scripts directory, and make will terminate. This is normal and you can just rerun make to complete the build.

Installation

You generally have two choices of how to install ZoneMinder. The traditional route involves compiling from source on the computer you intended to run it on. However increasingly helpful people have saved you that bother by creating pre-built packages. Below are examples of both approaches. Please note that other types of packages for other distributions are also usually available and normally have their own set of instructions, if necessary. These are normally listed elsewhere in the Wiki.

Installation from Source

For a new installation the next thing you will need to do is create your database and database users. So type the commands as follows when in the folder of the extracted zm files,

Create the ZoneMinder database 'zm' and populate it with the tables for ZoneMinder:

$ mysql
mysql> create database zm;
mysql> exit;
$ mysql zm < db/zm_create.sql   <This file doesn't exist until after 'make'>

Finally, create a MySQL user account for ZoneMinder:

$ mysql zm
mysql> grant select,insert,update,delete,lock tables,alter on zm.* to '<database user>'@localhost identified by '<database password>';
mysql> quit;
$ mysqladmin reload

You may need to supply a username and password to the mysql commands in the first place to give yourself sufficient privileges to perform the required commands. To do that it's something like: mysql -uroot -p<root database password> zm.

If you want to host your database on a different machine than that which ZoneMinder is running on then you will need to perform this step on the remote machine and reference the ZoneMinder machine instead of localhost. If you are running remote databases you probably already know all this, if you are not then don’t worry about it!

At this stage typing

make install

will install everything to the desired locations, you may need to su to root first though to give yourself adequate permissions. The installation routine will copy the binaries and scripts to your chosen install location, usually /usr/local/bin and then move zms (and nph-zms) to your cgi-bin area. It will then copy the web files to your chosen directory and ensure they have the right permissions, and install the ZoneMinder perl modules in the standard perl locations. It will also install a copy of the zm.conf file (generated by configure) to your system configuration area (e.g. /usr/local/etc). Finally it tries to link zm.php to index.php but will not overwrite an existing file if it already exists.

The 'zm' script does not get installed automatically as it is not necessary for the operation of the ZoneMinder setup per se and is not necessarily likely to work correctly for distributions other than those from the RedHat or Fedora families. However if you want to ensure that ZoneMinder is started on reboot etc copy it to your init.d directory, usually something like /etc/rc.d/init.d or /etc/inid.d and then add it by doing

chkconfig --add zm

or similar command for your distribution. ZoneMinder will then start up when your machine reboots and can be controlled (by the root user) by doing 'service zm start' or 'service zm stop' etc. You may need to use the ‘—levels’ parameter to chkconfig to ensure that ZoneMinder is started when you need it to.

If you do this you should find that you have files named S99zm in some of the /etc/rcX.d directories and K99zm in some of the others. The S99zm files are used for starting up ZoneMinder on system boot and the K99zm ones are used to close it on system shutdown. The 99 part is a priority, which may run from 0 to 99 and indicates where in the startup and shutdown sequences that ZoneMinder should start or stop. So S99zm means that ZoneMinder should be one of the last things to startup, which is good as it needs things like the database to be running first.

By the same token, the K00zm scripts indicate that ZoneMinder should be one of the first things to shut down. This prevents any nasty messages on your console about the database having gone away first and also will give ZoneMinder chance to shutdown in a controlled manner without introducing any corruption into the database or filesystem.

As mentioned above, this script is for Redhat, and related, distributions only. I would be grateful for any similar scripts for other distributions so if you know of one, or create one, then please send it to me.

If you are running a distribution which doesn’t support the zm script, or if you just prefer more direct control, you can now start ZoneMinder by typing

zmpkg.pl start

which, after a few seconds, should return without error. You can subsequently stop and restart everything by changing the ‘start’ parameter to ‘stop’ or ‘restart’.

Now fire up your web browser, point it at your zm.php and off you go.

Note, if you ever need to uninstall ZoneMinder you can do this by simply typing

make uninstall

though as with installation you may need to change user to have sufficient privileges. This will remove all installed files, however you will need to manually remove any databases you have created.

Installation from RPM

Installing from the RPM is distribution specific so make sure you download the correct RPM for the distribution that you are using.

All documents including this README are installed to the systems default document folder.

Fedora: /usr/share/doc/zoneminder-{version number}

Mandrake:

The packaged version of Zone Minder installs all binarys to /usr/lib/zm including the web pages. So don’t worry when you do not see any files installed to the root directory for your web server. The web pages for Apache are aliased by zoneminder.conf in the apache/conf.d directory which vary depending on your distribution:

Fedora: /etc/httpd/conf.d/zoneminder.conf

Mandrake:

The Configuration file for setting up the database is located at /etc/zm.conf and will need to be edited to add the user and password that you want Zone Minder to use. After you have installed the Zone Minder package this will be the first thing you want to do. So use your favourite editor and add in the user name and password you want Zone Minder to use. You can also change the database name if you would like.

vi /etc/zm.conf

Start the mysqld service so you can build the database

service mysqld start

Then run zminit to create the database (see discussion page if the command is not found)

/usr/lib/zm/bin/zminit

The user and password that zminit asks for are for the database only. For the user enter root and leave the password blank (unless of course you changed the password). You should see some information showing that it has created the database and no errors.

Set the run levels for the services that Zone Minder requires. I like to set the run levels to 3 and 5 with the following command:

chkconfig –levels 35 mysqld on
chkconfig –levels 35 httpd on

Now start the web server and Zone Minder:

service httpd start
service zm start          ; for source code distribtuions
service zoneminder start  ; for debian

You should now be able to access the Zone Minder console through the web browser http://localhost/zm

Log files will be located in /var/log/zm

Events are located at /var/lib/zm

Installation from a .deb

See also: http://www.zoneminder.com/wiki/index.php/Ubuntu_13.10_-_Apache_2.4_with_Zoneminder_configuration_changes

ZoneMinder is now in the Debian repositories. There are downloadable .deb files for Ubuntu for Edgy and Feisty. At this point it is in the repository for Gutsy. After you install, you will need to do some additional work, which is documented in the readme file included in the package. These steps have worked for several people as of the end of Summer 07.

Link Apache

sudo ln -s /etc/zm/apache.conf /etc/apache2/conf.d/zoneminder.conf

Restart Apache

sudo apache2ctl restart

suid zmfix

sudo chmod 4755 /usr/bin/zmfix

Run zmfix

zmfix -a

Fix export problem

sudo chown www-data.www-data /usr/share/zoneminder/temp

edit /etc/sysctl.conf and add the following lines (for 128meg shared mem)

kernel.shmmax = 134217728

Download cambozola.jar and put it in /usr/share/zoneminder Enable in options->Images.

Set path to ffmpeg in options -> Images /usr/bin/ffmpeg

test with xawtv (-nodga may be needed)

Configuring SELinux Policy

To allow zoneminder access attributes on selinux enabled systems you have to create a new policy. Note, that ZoneMinder will run with no issues on a system where SELinux has been disabled. First create a file named local_zoneminder.te (can be any name you want but if you use a name of a policy that already exists it will be overwritten).

module local_zoneminder 1.0; 

require { 
               type httpd_t;
               type initrc_var_run_t;
               type initrc_t;
               type v4l_device_t;
               type file_t;
              class unix_stream_socket { read connectto };
              class file { read lock };
              class shm { unix_read unix_write associate read write getattr };
              class chr_file getattr;
}

#============= httpd_t ============== 
allow httpd_t initrc_t:unix_stream_socket connectto;
allow httpd_t initrc_t:shm { unix_read unix_write associate read write getattr };
allow httpd_t initrc_var_run_t:file { read lock };
allow httpd_t v4l_device_t:chr_file getattr;


Next execute the following commands to create and load the policy module:

checkmodule -M -m -o local_zoneminder.mod local_zoneminder.te 
semodule_package -o local_zoneminder.pp -m local_zoneminder.mod 
semodule -i local_zoneminder.pp
  • NOTE: this policy module actually gives the httpd user in general permission to do more actions; this is still better than disabling selinux though.

Upgrading

Upgrading from Source

If you are upgrading from a previous version of ZoneMinder you should follow the Building instructions above. Before proceeding, ensure that any previous version of ZoneMinder has been stopped, then type

make install

to install the binaries, scripts, modules, web and configuration files.

The next step in an upgrade is to run the zmupdate.pl script to make any changes to the database or file system required by the new version. Ordinarily you can run this from your ZoneMinder build directory by doing

zmupdate.pl --version=<from version> [--user=<database user> --pass=<database password>]

where ‘from version’ relates to the version of ZM you are upgrading from, 1.21.1 for example, and not the version you are upgrading to. All updates from that version onwards will be applied; however zmupdate.pl will only work with upgrades from 1.19.0 onwards. The ‘user’ and ‘pass’ options allow you to specify a database user and password with sufficient privilege to ‘alter’ the structure of the database. This is not necessarily the database user you use for ZoneMinder.

The update script will offer you the chance to make a database backup before making any changes. You can use this to restore your database if the upgrade fails or if you simply wish to roll back in the future. Be aware that if you have a lot of entries in your database and/or limited disk space doing a backup may not be feasible or even work. Also the backup only applies to the database and will not save any images or other event detail saved on disk. If successful the backup will be saved in the current directory and will be named <database name>-<from version>.dump. Any previous backups of the same name will be overwritten without warning. The backup file is in the form of a simple sql script and can be used to restore the database simply by typing

mysql < zm-1.21.4.dump

for example.

After having done any backup, the database upgrade will be applied. Check that this is successful before continuing.

Once the upgrade process is complete, you can then restart ZoneMinder using the zmpkg.pl script or using the service control commands for your distribution. You should check /var/log/messages and the other ZoneMinder logs for the first few minutes to ensure that everything comes back up successfully.

Tutorial

Once configured, the ZoneMinder console appears through a web browser at http://localhost/zm/

Along the top there are several informational entries like the time of the last update and the current server load. There will also be an indication of the system state which will probably say ‘stopped’ to begin with. This is a link that you can click on to control the ZoneMinder system as a whole.

Below that are various other links including one detailing the current user (in authenticated mode only) and one allowing you to configure your bandwidth. This last one enables you to optimize your settings depending on where you are, the actual values relating to this are defined in the options. If you are using a browser on the same machine or network then choose high, over a cable or DSL link maybe choose medium and over a dialup choose low. You can experiment to see which is best. This setting is retained on a per machine basis with a persistent cookie. Also on this line are a number of other links that will be covered below.

Please bear in mind that from here on the descriptions of the web pages are based on what you will see if you are running as a fully authenticated user. If you are running in un-authenticated mode or as a less privileged user then some elements may not be shown or will be disabled. Authentication is an option that lets you specify whether anyone that goes to the ZoneMinder web pages must log themselves in, in order to be given permissions to perform certain tasks. Running in authenticated mode is recommended if your system is open to the internet at all. During installation a fully privileged user ‘admin’ has been created with a password also of ‘admin’. If you are using authentication you should change this password as soon as possible. Authenticated mode is enabled by checking the box "OPT_USE_AUTH" in the "System" tab of the Options and Users area.

Check that your Camera Works!

To help you get started on the video configuration the best thing is to check your camera with a tool like gucview cheese or xawtv (http://bytesex.org/xawtv/). Please note that just because you can see a video stream in these tools does not necessarily guarantee that your camera will work with ZoneMinder. This is because most tools just ‘map’ the video image through onto screen memory transparently without intercepting it, whereas ZoneMinder needs to capture the image and, usually, inspect it. This is called frame grabbing and to check it you should use the facility in xawtv, or other tool, to capture either one or more still images or possibly a movie. If this works and the images or movie are not garbage then the chances are that ZoneMinder will work fine also.

Once you have validated your camera run zmu -d <device_path> -q -v to get a dump of the settings (note, you will have to additionally supply a username and password to zmu if you are running in authenticated mode). You can then enter these values into the video related options of the monitor configuration panel. The '<device_path>' referred to here is the path to your video device file, for instance /dev/video0 etc. If 'zmu' gives you an error related to permissions run zmfix -a to make sure you can access all the video devices.

Start ZoneMinder

Zoneminder requires a web server and a background task:

 service httpd start
 service zoneminder start

Zoneminder captures video from the web server process (e.g. www-data or apache2), so that process must have access to any files or resources necessary.

Defining Monitors

To use ZoneMinder properly you need to define at least one Monitor. Essentially, a monitor is associated with a camera and can continually check it for motion detection and such like. So, next click 'Add New Monitor' to bring up the dialog. You will see a bunch of things you have to fill in.

ZM MPEG4 A211A 5.png

There are a small number of camera setups that ZoneMinder knows about and which can be accessed by clicking on the ‘Presets’ link. Selecting one of the presets will fill in the monitor configuration with appropriate values but you will still need to enter others and confirm the preset settings.

The options are divided into a set of tabs to make it easier to edit. You do not have to ‘save’ to change to different tab so you can make all the changes you require and then click ‘Save’ at the end. The individual options are explained in a little more detail below,

Monitor Tab

Name 
The name for your monitor. This should be made up of alphanumeric characters (a-z,A-Z,0-9) and hyphen (-) and underscore(_) only. Whitespace is not allowed.
Source Type 
This determines whether the camera is a local one attached to a physical video or USB port on your machine, a remote network camera or an image source that is represented by a file (for instance periodically downloaded from a alternate location). Choosing one or the other affects which set of options are shown in the Source tab.
Function 
This essentially defines what the monitor is doing. This can be one of the following;
  • None – The monitor is currently disabled. No streams can be viewed or events generated. Nothing is recorded.
  • Monitor – The monitor is only available for live streaming. No image analysis is done so no alarms or events will be generated, and nothing will be recorded.
  • Modect – or MOtion DEteCTtion. All captured images will be analysed and events generated with recorded video where motion is detected.
  • Record – The monitor will be continuously recorded. Events of a fixed-length will be generated regardless of motion, analogous to a conventional time-lapse video recorder. No motion detection takes place in this mode.
  • Mocord – The monitor will be continuously recorded, with any motion being highlighted within those events.
  • Nodect – or No DEteCTtion. This is a special mode designed to be used with external triggers. In Nodect no motion detection takes place but events are recorded if external triggers require it.
Generally speaking it is best to choose ‘Monitor’ as an initial setting here.
Enabled 
The enabled field indicates whether the monitor should be started in an active mode or in a more passive state. You will nearly always want to check this box, the only exceptions being when you want the camera to be enabled or disabled by external triggers or scripts. If not enabled then the monitor will not create any events in response to motion or any other triggers.
Linked Monitors 
This field allows you to select other monitors on your system that act as triggers for this monitor. So if you have a camera covering one aspect of your property you can force all cameras to record while that camera detects motion or other events. You can either directly enter a comma separated list of monitor ids or click on ‘Select’ to choose a selection. Be very careful not to create circular dependencies with this feature however you will have infinitely persisting alarms which is almost certainly not what you want! To unlink monitors you can ctrl-click.
Maximum FPS 
On some occasions you may have one or more cameras capable of high capture rates but find that you generally do not require this performance at all times and would prefer to lighten the load on your server. This option permits you to limit the maximum capture rate to a specified value. This may allow you to have more cameras supported on your system by reducing the CPU load or to allocate video bandwidth unevenly between cameras sharing the same video device. This value is only a rough guide and the lower the value you set the less close the actual FPS may approach it especially on shared devices where it can be difficult to synchronise two or more different capture rates precisely. This option controls the maximum FPS in the circumstance where no alarm is occurring only. (Note for IP cameras: ZoneMinder has no way to set or limit the mjpeg stream the camera passes, some cams you can set this through the url string, others do not. So if you're using mjpeg feeds you must NOT throttle here at the server end, only the cam end. If you want to use this feature, the server to throttle, then you MUST use jpeg instead of mjpeg method to get picture from the camera)
Alarm Maximum FPS 
If you have specified a Maximum FPS it may be that you don’t want this limitation to apply when your monitor is recording motion or other event. This setting allows you to override the Maximum FPS value if this circumstance occurs. As with the Maximum FPS setting leaving this blank implies no limit so if you have set a maximum fps in the previous option then when an alarm occurs this limit would be ignored and ZoneMinder would capture as fast as possible for the duration of the alarm, returning to the limited value after the alarm has concluded. Equally you could set this to the same, or higher (or even lower) value than Maximum FPS for more precise control over the capture rate in the event of an alarm.
Reference Image Blend %ge 
Each analysed image in ZoneMinder is a composite of previous images and is formed by applying the current image as a certain percentage of the previous reference image. Thus, if we entered the value of 10 here, each image’s part in the reference image will diminish by a factor of 0.9 each time round. So a typical reference image will be 10% the previous image, 9% the one before that and then 8.1%, 7.2%, 6.5% and so on of the rest of the way. An image will effectively vanish around 25 images later than when it was added. This blend value is what is specified here and if higher will make slower progressing events less detectable as the reference image would change more quickly. Similarly events will be deemed to be over much sooner as the reference image adapts to the new images more quickly. In signal processing terms the higher this value the steeper the event attack and decay of the signal. It depends on your particular requirements what the appropriate value would be for you but start with 10 here and adjust it (usually down) later if necessary.
Triggers 
This small section lets you select which triggers will apply if the run mode has been set to ‘triggered’ above. The most common trigger is X10 and this will appear here if you indicated that your system supported it during installation. Only X10 is supported as a shipped trigger with ZoneMinder at present but it is possible that other triggers will become available as necessary. You can also just use ‘cron’ jobs or other mechanisms to actually control the camera and keep them completely outside of the ZoneMinder settings. The zmtrigger.pl script is also available to implement custom external triggering.

Source Tab (local device)

Device Path/Channel 
Enter the full path to the device file that your camera is attached to, e.g. /dev/video0. Some video devices, e.g. BTTV cards support multiple cameras on one device so in this case enter the channel number in the Channel box or leave it at zero if you're using a USB camera or one with just one channel. Look in Supported Hardware section, how to see if your capture card or USB webcam is supported or not, and what extra settings you may have to do, to make it work.
Device Format 
Enter the video format of the video stream. This is defined in various system files (e.g. /usr/include/linux/videodev.h) but the two most common are 0 for PAL and 1 for NTSC.
Capture Palette 
Finally for the video part of the configuration enter the colour depth. ZoneMinder supports a handful of the most common palettes, so choose one here. If in doubt try grey first, and then 24 bit colour. If neither of these work very well then YUV420P or one of the others probably will. There is a slight performance penalty when using palettes other than grey or 24 bit colour as an internal conversion is involved. These other formats are intended to be supported natively in a future version but for now if you have the choice choose one of grey or 24 bit colour.
Capture Width/Height 
The dimensions of the video stream your camera will supply. If your camera supports several just enter the one you'll want to use for this application, you can always change it later. However I would recommend starting with no larger than 320x240 or 384x288 and then perhaps increasing and seeing how performance is affected. This size should be adequate in most cases. Some cameras are quite choosy about the sizes you can use here so unusual sizes such as 197x333 should be avoided initially.
Keep aspect ratio
When typing in the dimensions of monitors you can click this checkbox to ensure that the width stays in the correct ratio to the height, or vice versa. It allows height to be calculated automatically from width (or vice versa) according to preset aspect ratio. This is preset to 4:3 but can be amended globally via the Options->Config->ZM_DEFAULT_ASPECT_RATIO setting. Aside from 4:3 which is the usual for network and analog cameras another common setting is 11:9 for CIF (352x288) based sources.
Orientation 
If your camera is mounted upside down or at right angles you can use this field to specify a rotation that is applied to the image as it is captured. This incurs an additional processing overhead so if possible it is better to mount your camera the right way round if you can. If you choose one of the rotation options remember to switch the height and width fields so that they apply, e.g. if your camera captures at 352x288 and you choose ‘Rotate Right’ here then set the height to be 352 and width to be 288. You can also choose to ‘flip’ the image if your camera provides mirrored input.

Source Tab (remote device)

Remote Host/Port/Path 
Use these fields to enter the full URL of the camera. Basically if your camera is at http://camserver.home.net:8192/cameras/camera1.jpg then these fields will be camserver.home.net, 8192 and /cameras/camera1.jpg respectively. Leave the port at 80 if there is no special port required. If you require authentication to access your camera then add this onto the host name in the form <username>:<password>@<hostname>.com. This will usually be 24 bit colour even if the image looks black and white. Look in Supported Hardware > Network Cameras section, how to obtain these strings that may apply to your camera.
Remote Image Colours 
Specify the amount of colours in the captured image. Unlike with local cameras changing this has no controlling effect on the remote camera itself so ensure that your camera is actually capturing to this palette beforehand.
Capture Width/Height 
Make sure you enter here the same values as they are in the remote camera's internal setting.
Keep aspect ratio
As per local devices.
Orientation 
As per local devices.

For an example to setup a MPEG-4 camera see: How_to_Setup_an_Axis211A_with_MPEG-4_streaming

Source Tab (ffmpeg)

Source Path 
Use this field to enter the full URL of the stream or file. Look in Supported Hardware > Network Cameras section, how to obtain these strings that may apply to your camera. RTSP streams may be specified here.
Source Colours 
Specify the amount of colours in the captured image. Unlike with local cameras changing this has no controlling effect on the remote camera itself so ensure that your camera is actually capturing to this palette beforehand.
Capture Width/Height 
Make sure you enter here the same values as they are in the remote camera's internal setting.
Keep aspect ratio
As per local devices.
Orientation 
As per local devices.

Source Tab (file device)

File Path 
Enter the full path to the file to be used as the image source.
File Colours 
Specify the amount of colours in the image. Usually 24 bit colour.
Capture Width/Height
As per local devices.
Keep aspect ratio
As per local devices.
Orientation 
As per local devices.

Timestamp Tab

Timestamp Label Format 
This relates to the timestamp that is applied to each frame. It is a ‘strftime’ style string with a few extra tokens. You can add %f to add the decimal hundredths of a second to the frame timestamp, so %H:%M:%S.%f will output time like 10:45:37.45. You can also use %N for the name of the monitor and %Qwhich will be filled by any of the ‘show text’ detailed in the zmtriggers.pl section.
Timestamp Label X/Y 
The X and Y values determine where to put the timestamp. A value of 0 for the X value will put it on the left side of the image and a Y value of 0 will place it at the top of the image. To place the timestamp at the bottom of the image use a value eight less than the image height.

Buffers Tab

Image Buffer Size 
This option determines how many frames are held in the ring buffer at any one time. The ring buffer is the storage space where the last ‘n’ images are kept, ready to be resurrected on an alarm or just kept waiting to be analysed. It can be any value you like with a couple of provisos, (see next options). However it is stored in shared memory and making it too large especially for large images with a high colour depth can use a lot of memory. A value of no more than 50 is usually ok. If you find that your system will not let you use the value you want it is probably because your system has an arbitrary limit on the size of shared memory that may be used even though you may have plenty of free memory available. This limit is usually fairly easy to change, see the Troubleshooting section for details.
Warm-up Frames 
This specifies how many frames the analysis daemon should process but not examine when it starts. This allows it to generate an accurate reference image from a series of images before looking too carefully for any changes. I use a value of 25 here, too high and it will take a long time to start, too low and you will get false alarms when the analysis daemon starts up.
Pre/Post Event Image Buffer 
These options determine how many frames from before and after an event should be preserved with it. This allows you to view what happened immediately prior and subsequent to the event. A value of 10 for both of these will get you started but if you get a lot of short events and would prefer them to run together to form fewer longer ones then increase the Post Event buffer size. The pre-event buffer is a true buffer and should not really exceed half the ring buffer size. However the post-event buffer is just a count that is applied to captured frames and so can be managed more flexibly. You should also bear in mind the frame rate of the camera when choosing these values. For instance a network camera capturing at 1FPS will give you 10 seconds before and after each event if you chose 10 here. This may well be too much and pad out events more than necessary. However a fast video card may capture at 25FPS and you will want to ensure that this setting enables you to view a reasonable time frame pre and post event.
Stream Replay Image Buffer
This option ...
Alarm Frame Count 
This option allows you to specify how many consecutive alarm frames must occur before an alarm event is generated. The usual, and default, value is 1 which implies that any alarm frame will cause or participate in an event. You can enter any value up to 16 here to eliminate bogus events caused perhaps by screen flickers or other transients. Values over 3 or 4 are unlikely to be useful however. Please note that if you have statistics recording enabled then currently statistics are not recorded for the first ‘Alarm Frame Count’-1 frames of an event. So if you set this value to 5 then the first 4 frames will be missing statistics whereas the more usual value of 1 will ensure that all alarm frames have statistics recorded.

Control Tab

Note: This tab and its options will only appear if you have selected the ZM_OPT_CONTROL option to indicate that your system contains cameras which are able to be controlled via Pan/Tilt/Zoom or other mechanisms. See the Camera Control section elsewhere in this document for further details on camera control protocols and methods.

Controllable 
Check this box to indicate your camera can be controlled.
Control Type 
Select the control type that is appropriate for your camera. ZoneMinder ships with a small number of predefined control protocols which will works with some cameras without modification but which may have to amended to function with others, Choose the edit link to create new control types or to edit the existing ones.
Control Device 
This is the device that is used to control your camera. This will normally be a serial or similar port. If your camera is a network camera, you will generally not need to specify a control device.
Control Address 
This is the address of your camera. Some control protocols require that each camera is identified by a particular, usually numeric, id. If your camera uses addressing then enter the id of your camera here. If your camera is a network camera then you will usually need to enter the hostname or IP address of it here. This is ordinarily the same as that given for the camera itself.
Auto Stop Timeout 
Some cameras only support a continuous mode of movement. For instance you tell the camera to pan right and then when it is aligned correctly you tell it to stop. In some cases it is difficult to time this precisely over a web interface so this option allows you to specify an automatic timeout where the command will be automatically stopped. So a value of 0.25 here can tell the script to stop moving a quarter of a second after starting. This allows a more precise method of fine control. If this value is left blank or at zero it will be ignored, if set then it will be used as the timeout however it will only be applied for the lower 25% of possible speed ranges. In other words if your camera has a pan speed range of 1 to 100 then selecting to move at 26 or over will be assumed to imply that you want a larger movement that you can control yourself and no timeout will be applied. Selecting motion at lower speeds will be interpreted as requiring finer control and the automatic timeout will be invoked.
Track Motion 
This and the following four options are used with the experimental motion function. This will only work if your camera supports mapped movement modes where a point on an image can be mapped to a control command. This is generally most common on network cameras but can be replicated to some degree on other cameras that support relative movement modes. See the Camera Control section for more details. Check this box to enable motion tracking.
Track Delay 
This is the number of seconds to suspend motion detection for following any movement that the camera may make to track motion.
Return Location 
If you camera supports a ‘home’ position or presets you can choose which preset the camera should return to after tracking motion.
Return Delay 
This is the delay, in seconds, once motion has stopped being detected, before the camera returns to any defined return location.

X10 Tab

Note: This tab and its options will only appear if you have indicated that your system supports the X10 home automation protocol during initial system configuration.

X10 Activation String 
The contents of this field determine when a monitor starts and/or stops being active when running in ‘Triggered; mode and with X10 triggers. The format of this string is as follows,
  • n : If you simply enter a number then the monitor will be activated when an X10 ON signal for that unit code is detected and will be deactivated when an OFF signal is detected.
  •  !n : This inverts the previous mode, e.g. !5 means that the monitor is activated when an OFF signal for unit code 5 is detected and deactivated by an ON.
  • n+ : Entering a unit code followed by + means that the monitor is activated on receipt of a ON signal for that unit code but will ignore the OFF signal and as such will not be deactivated by this instruction. If you prepend a '!' as per the previous definition it similarly inverts the mode, i.e. the ON signal deactivates the monitor.
  • n+<seconds> : As per the previous mode except that the monitor will deactivate itself after the given number of seconds.
  • n- : Entering a unit code followed by - means that the monitor is deactivated on receipt of a OFF signal for that unit code but will ignore the ON signal and as such will not be activated by this instruction. If you prepend a '!' as per the previous definition it similarly inverts the mode, i.e. the OFF signal activates the monitor.
  • n-<seconds> : As per the previous mode except that the monitor will activate itself after the given number of seconds.
You can also combine several of these expressions to by separating them with a comma to create multiple circumstances of activation. However for now leave this blank.
X10 Input Alarm String 
This has the same format as the previous field but instead of activating the monitor with will cause a forced alarm to be generated and an event recorded if the monitor is Active. The same definition as above applies except that for activated read alarmed and for deactivated read unalarmed(!). Again leave this blank for now.
X10 Output Alarm String 
This X10 string also has the same format as the two above options. However it works in a slightly different way. Instead of ZoneMinder reacting to X10 events this option controls how ZoneMinder emits X10 signals when the current monitor goes into or comes out of the alarm state. Thus just entering a number will cause the ON signal for that unit code to be sent when going into alarm state and the OFF signal when coming out of alarm state. Similarly 7+30 will send the unit code 7 ON signal when going into alarm state and the OFF signal 30 seconds later regardless of state. The combination of the X10 instruction allows ZoneMinder to react intelligently to, and also assume control of, other devices when necessary. However the indiscriminate use of the Input Alarm and Output Alarm signals can cause some horrendous race conditions such as a light going on in response to an alarm which then causes an alarm itself and so on. Thus some circumspection is required here. Leave this blank for now anyway.

Misc Tab

Event Prefix 
By default events are named ‘Event-<event id>’, however you are free to rename them individually as you wish. This option lets you modify the event prefix, the ‘Event-‘ part, to be a value of your choice so that events are named differently as they are generated. This allows you to name events according to which monitor generated them.
Section Length 
This specifies the length (in seconds) of any fixed length events produced when the monitor function is ‘Record’ or ‘Mocord’. Otherwise it is ignored. This should not be so long that events are difficult to navigate nor so short that too many events are generated. A length of between 300 and 900 seconds I recommended.
Frame Skip 
This setting also applies only to the ‘Record’ or ‘Mocord’ functions and specifies how many frames should be skipped in the recorded events. The default setting of zero results in every captured frame being saved. Using a value of one would mean that one frame is skipped between each saved, two means that two frames are skipped between each saved frame etc. An alternate way of thinking is that one in every ‘Frame Skip + 1’ frames is saved. The point of this is to ensure that saved events do not take up too much space unnecessarily whilst still allowing the camera to capture at a fairly high frame rate. The alternate approach is to limit the capture frame rate which will obviously affect the rate at which frames are saved.
FPS Report Interval 
How often the current performance in terms of Frames Per Second is output to the system log. Not used in any functional way so set it to maybe 1000 for now. If you watch /var/log/messages (normally) you will see this value being emitted at the frequency you specify both for video capture and processing.
Default Scale 
If your monitor has been defined with a particularly large or small image size then you can choose a default scale here with which to view the monitor so it is easier or more visible from the web interface.
Web Colour 
Some elements of ZoneMinder now use colours to identify monitors on certain views. You can select which colour is used for each monitor here. Any specification that is valid for HTML colours is valid here, e.g. ‘red’ or ‘#ff0000’. A small swatch next to the input box displays the colour you have chosen.

Finally, click 'Save' to add your monitor.

On the main console listing you will now see your monitor and some of its vital statistics. Most columns are also links and you get to other functions of ZoneMinder by choosing the appropriate one. Describing them left to right, they are as follows.

The first column is the Id, clicking on this gives you the opportunity to edit any of the settings you have just defined your monitor to have.

The next column is the Name column, clicking on this will give you the watch window where you can view a live feed from your camera along with recent events. This is described more fully below.

Following that are the Function and Source columns, which may be represented in various colours. Initially both will be showing red. This means that that monitor is not configured for any function and as a consequence has no zmc (capture) daemon running on it. If it were orange it would mean that a zmc daemon was running but no zma (analysis) daemon and green means both are running. In our case it is red because we defined the Monitor to have a Function of None so no daemons are required.

To get the daemons up and running you can either click on the source listed in the Source column and edit the monitor properties or click on the Function listed and change it to ’Monitor’, which will ensure that one or more appropriate daemons are started automatically. You need to ensure that you have started ZoneMinder before any of these settings actually has any effect.

Having a device status of red or orange does not necessarily constitute an error if you have deliberately disabled a monitor or have just put it into Passive mode.

If you have several cameras (and thus monitors) on a device the device status colour reflects all of them for the capture daemon. So if just one monitor is active then the daemon is active for both even if all the other monitors are switched off.

Once you have changed the function of your monitor, the main console window will be updated to reflect this change. If your device status does not go green then check your system and web server logs to see if it's something obvious.

You can now add further monitors if you have cameras set up to support them. Once you have one or more monitors you may notice the '<n> Monitors' title becomes a link. Clicking on this link will open up a window which allows you to assign your monitors to groups. These let you select certain monitors to view. For instance you may only wish to view outdoor monitors while indoors. You can also choose to view all of them. If you choose a group then your selection will be remembered via a cookie and will be used until you change it. You can call your groups anything you like, though ‘Mobile’ has a special meaning (see Mobile Devices below).

There may also be a ‘Cycle’ link which allows you to cycle through a shot from each of your monitors (in the selected group unless they are switched off) and get a streamed or still image from each in turn. Similarly if you see a link titled ‘Montage’ it will allow you view all your active enabled cameras (in the selected group) simultaneously. Be aware however that this can consume large amounts of bandwidth and CPU so should not be used continuously unless you have resource to burn.

Defining Zones

For a very brief step by step guide check out Configuring motion detection .

The next important thing to do with a new monitor is set up Zones for it to use. By default you'll already have one generated for you when you created your monitor but you might want to modify it or add others. Click on the Zones column for your monitor and you should see a small popup window appear which contains an image from your camera overlain with a stippled pattern representing your zone. In the default case this will cover the whole image. The colour of the zones appearing here is determined by what type they are. The default zone is Active and so will be red, Inclusive zones are orange, exclusive zones are purple, preclusive zones are blue and inactive zones are white.

Beneath the zones image will be a table containing a listing of your zones. Clicking on either the relevant bit of the image or on the Id or Name in the table will bring up another window where you can edit the particulars for your Zones. For more information on defining or editing a zone, see Defining Zones.

Viewing Monitors

As this point you should have one or more Monitors running with one or more Zones each. Returning to the main Console window you will see your monitors listed once more. The columns not explored so far are the Monitor name, and various event totals for certain periods of time. Clicking on any of the event totals will bring up a variation on the same window but click on the Monitor name for now. If it is not a link then this means that that monitor is not running so ensure that you have started ZoneMinder and that your Monitor function is not set to ‘None’. If the link works, clicking on it will pop another window up which should be scaled to contain a heading, an image from your monitor, a status and a list of recent events if any have been generated.

Depending on whether you are able to view a streamed image or not the image frame will either be this stream or a series of stills. You have the option to change from one to the other (if available) at the centre of the top heading. Also along the top are a handful of other links. These let you change the scale of the image stream, modify image settings (for local devices) or close the window. If you have cameras that can be controlled, a ‘Control’ link should also be present which is described below.

The image should be self-explanatory but if it looks like garbage it is possible that the video configuration is wrong so look in your system error log and check for or report anything unusual. The centre of the window will have a tiny frame that just contains a status; this will be 'Idle', 'Alarm' or 'Alert' depending on the function of the Monitor and what's going on in the field of view. Idle means nothing is happening, Alarm means there is an alarm in progress and Alert means that an alarm has happened and the monitor is ‘cooling down’, if another alarm is generated in this time it will just become part of the same event. These indicators are colour coded in green, red and amber.

By default if you have minimised this window or opened other windows in front it will pop up to the front if it goes to Alarm state. This behaviour can be turned off in ‘options’ if required. You can also specify a sound file in the configuration, which will be played when an alarm occurs to alert you to the fact if you are not in front of your computer. This should be a short sound of only a couple of seconds ideally. Note that as the status is refreshed every few seconds it is possible for this not to alert you to every event that takes place, so you shouldn't rely on it for this purpose if you expect very brief events. Alternatively you can decrease the refresh interval for this window in the configuration though having too frequent refreshing may impact on performance.

Below the status is a list of recent events that have occurred, by default this is a listing of just the last 10 but clicking on 'All' will give you a full list and 'Archive' will take you to the event archive for this monitor, more on this later. Clicking on any of the column headings will sort the events appropriately.

From here you can also delete events if you wish. The events themselves are listed with the event id, and event name (which you can change), the time that the event occurred, the length of the event including any preamble and postamble frames, the number of frames comprising the event with the number that actually contain an alarm in brackets and finally a score. This column lists the average score per alarm frame as well as the maximum score that any alarm frame had.

The score is an arbitrary value that essentially represents the percentage of pixels in the zone that are in blobs divided by the square root of the number of blobs and then divided by the size of the zone. This gives a nominal maximum of 100 for a zone and the totals for each zone are added together, Active zones scores are added unchanged, Inclusive zones are halved first and Exclusive zones are doubled. In reality values are likely to be much less than 100 but it does give a simple indication of how major the event was.

Controlling Monitors

Settings for PTZ on an Axis213

For step by step instructions on setting up pan tilt zoom check out Axis213 with pan tilt zoom

If you have defined your system as having controllable monitors and you are looking at a monitor that is configured for control, then clicking on the ‘Control’ link along the top of the window will change the short event listing area to a control area. The capabilities you have defined earlier determine exactly what is displayed in this window. Generally you will have a Pan/Tilt control area along with one or subsidiary areas such as zoom or focus control to the side. If you have preset support then these will be near the bottom of the window. The normal method of controlling the monitor is by clicking on the appropriate graphics which then send a command via the control script to the camera itself. This may sometimes take a noticeable delay before the camera responds.

It is usually the case that the control arrows are sensitive to where you click on them. If you have a camera that allows different speeds to be used for panning or zooming etc then clicking near the point of the arrow will invoke the faster speed whilst clicking near the base of the arrow will be slower. If you have defined continuous motion then ongoing activities can be stopped by clicking on the area between the arrows, which will either be a graphic in the case of pan/tilt controls or a word in the case of zoom and focus controls etc.

Certain control capabilities such as mapped motion allow direct control by clicking on the image itself when used in browsers which support streamed images directly. Used in this way you can just click on the area of the image that interests you and the camera will centre on that spot. You can also use direct image control for relative motion when the area of the image you click on defines the direction and the distance away from the centre of the image determines the speed. As it is not always very easy to estimate direction near the centre of the image, the active area does not start until a short distance away from the centre, resulting in a ‘dead’ zone in the middle of the image.

Filtering Events

For a very brief howto guide on this topic check out Event Filter.

The other columns on the main console window contain various event totals for your monitors over the last hour, day, week and month as well as a grand total and a total for events that you may have archived for safekeeping. Clicking on one of these totals or on the 'All' or 'Archive' links from the monitor window described above will present you with a new display. This is the full event window and contains a list of events selected according to a filter which will also pop up in its own window. Thus if you clicked on a 'day' total the filter will indicate that this is the period for which events are being filtered. The event listing window contains a similar listing to the recent events in the monitor window. The primary differences are that the frames and alarm frames and the score and maximum score are now broken out into their own columns, all of which can be sorted by clicking on the heading. Also this window will not refresh automatically, rather only on request. Other than that, you can choose to view events here or delete them as before.

The other window that appeared is a filter window. You can use this window to create your own filters or to modify existing ones. You can even save your favourite filters to re-use at a future date. Filtering itself is fairly simple; you first choose how many expressions you'd like your filter to contain. Changing this value will cause the window to redraw with a corresponding row for each expression. You then select what you want to filter on and how the expressions relate by choosing whether they are 'and' or 'or' relationships. For filters comprised of many expressions you will also get the option to bracket parts of the filter to ensure you can express it as desired. Then if you like choose how you want your results sorted and whether you want to limit the amount of events displayed.

There are several different elements to an event that you can filter on, some of which require further explanation. These are as follows, 'Date/Time' which must evaluate to a date and a time together, 'Date' and 'Time' which are variants which may only contain the relevant subsets of this, 'Weekday' which as expected is a day of the week.

All of the preceding elements take a very flexible free format of dates and time based on the PHP strtotime function (http://www.php.net/manual/en/function.strtotime.php). This allows values such as 'last Wednesday' etc to be entered. I recommend acquainting yourself with this function to see what the allowed formats are. However automated filters are run in perl and so are parsed by the Date::Manip package. Not all date formats are available in both so if you are saved your filter to do automatic deletions or other tasks you should make sure that the date and time format you use is compatible with both methods. The safest type of format to use is ‘-3 day’ or similar with easily parseable numbers and units are in English.

The other things you can filter on are all fairly self explanatory, except perhaps for 'Archived' which you can use to include or exclude Archived events. In general you'll probably do most filtering on un-archived events. There are also two elements, Disk Blocks and Disk Percent which don’t directly relate to the events themselves but to the disk partition on which the events are stored. These allow you to specify an amount of disk usage either in blocks or in percentage as returned by the ‘df’ command. They relate to the amount of disk space used and not the amount left free. Once your filter is specified, clicking 'submit' will filter the events according to your specification. As the disk based elements are not event related directly if you create a filter and include the term ‘DiskPercent > 95’ then if your current disk usage is over that amount when you submit the filter then all events will be listed whereas if it is less then none at all will. As such the disk related terms will tend to be used mostly for automatic filters (see below). If you have created a filter you want to keep, you can name it and save it by clicking 'Save'.

If you do this then the subsequent dialog will also allow you specify whether you want this filter automatically applied in order to delete events or upload events via ftp to another server and mail notifications of events to one or more email accounts. Emails and messages (essentially small emails intended for mobile phones or pagers) have a format defined in the Options screen, and may include a variety of tokens that can be substituted for various details of the event that caused them. This includes links to the event view or the filter as well as the option of attaching images or videos to the email itself. Be aware that tokens that represent links may require you to log in to access the actual page, and sometimes may function differently when viewed outside of the general ZoneMinder context. The tokens you can use are as follows.

 %EI% Id of the event
 %EN% Name of the event
 %EC% Cause of the event
 %ED% Event description
 %ET% Time of the event
 %EL% Length of the event
 %EF% Number of frames in the event
 %EFA% Number of alarm frames in the event
 %EST% Total score of the event
 %ESA% Average score of the event
 %ESM% Maximum score of the event
 %EP% Path to the event
 %EPS% Path to the event stream
 %EPI% Path to the event images
 %EPI1% Path to the first alarmed event image
 %EPIM% Path to the (first) event image with the highest score
 %EI1% Attach first alarmed event image
 %EIM% Attach (first) event image with the highest score
 %EV% Attach event mpeg video
 %MN% Name of the monitor
 %MET% Total number of events for the monitor
 %MEH% Number of events for the monitor in the last hour
 %MED% Number of events for the monitor in the last day
 %MEW% Number of events for the monitor in the last week
 %MEM% Number of events for the monitor in the last month
 %MEA% Number of archived events for the monitor
 %MP% Path to the monitor window
 %MPS% Path to the monitor stream
 %MPI% Path to the monitor recent image
 %FN% Name of the current filter that matched
 %FP% Path to the current filter that matched
 %ZP% Path to your ZoneMinder console

Finally you can also specify a script which is run on each matched event. This script should be readable and executable by your web server user. It will get run once per event and the relative path to the directory containing the event in question. Normally this will be of the form <MonitorName>/<EventId> so from this path you can derive both the monitor name and event id and perform any action you wish. Note that arbitrary commands are not allowed to be specified in the filter, for security the only thing it may contain is the full path to an executable. What that contains is entirely up to you however.

Filtering is a powerful mechanism you can use to eliminate events that fit a certain pattern however in many cases modifying the zone settings will better address this. Where it really comes into its own is generally in applying time filters, so for instance events that happen during weekdays or at certain times of the day are highlighted, uploaded or deleted. Additionally using disk related terms in your filters means you can automatically create filters that delete the oldest events when your disk gets full. Be warned however that if you use this strategy then you should limit the returned results to the amount of events you want deleted in each pass until the disk usage is at an acceptable level. If you do not do this then the first pass when the disk usage is high will match, and then delete, all events unless you have used other criteria inside of limits. ZoneMinder ships with a sample filter already installed, though disabled. The PurgeWhenFull filter can be used to delete the oldest events when your disk starts filling up. To use it you should select and load it in the filter interface, modify it to your requirements, and then save it making you sure you check the ‘Delete all matches’ option. This will then run in the background and ensure that your disk does not fill up with events.


Relative items in date strings

Relative items adjust a date (or the current date if none) forward or backward. The effects of relative items accumulate. Here are some examples:


1 year 1 year ago 3 years 2 days

The unit of time displacement may be selected by the string ‘year’ or ‘month’ for moving by whole years or months. These are fuzzy units, as years and months are not all of equal duration. More precise units are ‘fortnight’ which is worth 14 days, ‘week’ worth 7 days, ‘day’ worth 24 hours, ‘hour’ worth 60 minutes, ‘minute’ or ‘min’ worth 60 seconds, and ‘second’ or ‘sec’ worth one second. An ‘s’ suffix on these units is accepted and ignored.

The unit of time may be preceded by a multiplier, given as an optionally signed number. Unsigned numbers are taken as positively signed. No number at all implies 1 for a multiplier. Following a relative item by the string ‘ago’ is equivalent to preceding the unit by a multiplier with value -1.

The string ‘tomorrow’ is worth one day in the future (equivalent to ‘day’), the string ‘yesterday’ is worth one day in the past (equivalent to ‘day ago’).

The strings ‘now’ or ‘today’ are relative items corresponding to zero-valued time displacement, these strings come from the fact a zero-valued time displacement represents the current time when not otherwise changed by previous items. They may be used to stress other items, like in ‘12:00 today’. The string ‘this’ also has the meaning of a zero-valued time displacement, but is preferred in date strings like ‘this thursday’.

When a relative item causes the resulting date to cross a boundary where the clocks were adjusted, typically for daylight saving time, the resulting date and time are adjusted accordingly.

The fuzz in units can cause problems with relative items. For example, ‘2003-07-31 -1 month’ might evaluate to 2003-07-01, because 2003-06-31 is an invalid date. To determine the previous month more reliably, you can ask for the month before the 15th of the current month. For example:


$ date -R
Thu, 31 Jul 2003 13:02:39 -0700
$ date --date='-1 month' +'Last month was %B?'
Last month was July?
$ date --date="$(date +%Y-%m-15) -1 month" +'Last month was %B!'
Last month was June!


As this applies to ZoneMinder filters, you might want to search for events in a period of time, or maybe for example create a purge filter that removes events older than 30 days. For the later you would want at least two lines in your filter. The first line should be:

[<Archive Status> <equal to> <Unarchived Only>] 

as you don't want to delete your archived events.

Your second line to find events older than 30 days would be:

[and <Date><less than> -30 days] 

You use "less than" to indicate that you want to match events before the specified date, and you specify "-30 days" to indicate a date 30 days before the time the filter is run. Of course you could use 30 days ago as well(?).

You should always test your filters before enabling any actions based on them to make sure they consistently return the results you want. You can use the submit button to see what events are returned by your query.

Viewing Events

From the monitor or filtered events listing you can now click on an event to view it in more detail. If you have streaming capability you will see a series of images that make up the event. Under that you should also see a progress bar. Depending on your configuration this will either be static or will be filled in to indicate how far through the event you are. By default this functionality is turned off for low bandwidth settings as the image delivery tends to not be able to keep up with real-time and the progress bar cannot take this into account. Regardless of whether the progress bar updates, you can click on it to navigate to particular points in the events.

You will also see a link to allow you to view the still images themselves. If you don't have streaming then you will be taken directly to this page. The images themselves are thumbnail size and depending on the configuration and bandwidth you have chosen will either be the full images scaled in your browser of actual scaled images. If it is the latter, if you have low bandwidth for example, it may take a few seconds to generate the images. If thumbnail images are required to be generated, they will be kept and not re-generated in future. Once the images appear you can mouse over them to get the image sequence number and the image score.

You will notice for the first time that alarm images now contain an overlay outlining the blobs that represent the alarmed area. This outline is in the colour defined for that zone and lets you see what it was that caused the alarm. Clicking on one of the thumbnails will take you to a full size window where you can see the image in all its detail and scroll through the various images that make up the event. If you have the ZM_RECORD_EVENT_STATS option on, you will be able to click the 'Stats' link here and get some analysis of the cause of the event. Should you determine that you don't wish to keep the event, clicking on Delete will erase it from the database and file system. Returning to the event window, other options here are renaming the event to something more meaningful, refreshing the window to replay the event stream, deleting the event, switching between streamed and still versions of the event (if supported) and generating an MPEG video of the event (if supported).

These last two options require further explanation. Archiving an event means that it is kept to one side and not displayed in the normal event listings unless you specifically ask to view the archived events. This is useful for keeping events that you think may be important or just wish to protect. Once an event is archived it can be deleted or unarchived but you cannot accidentally delete it when viewing normal unarchived events.

The final option of generating an MPEG video is still somewhat experimental and its usefulness may vary. It uses the open source ffmpeg encoder to generate short videos, which will be downloaded to your browsing machine or viewed in place. When using the ffmpeg encoder, ZoneMinder will attempt to match the duration of the video with the duration of the event. Ffmpeg has a particularly rich set of options and you can specify during configuration which additional options you may wish to include to suit your preferences. In particular you may need to specify additional, or different, options if you are creating videos of events with particularly slow frame rates as some codecs only support certain ranges of frame rates. A common value for FFMPEG_OUTPUT_OPTIONS under Options > Images might be '-r 25 -b 800k' for 25 fps and 800 kbps. Details of these options can be found in the documentation for the encoders and is outside the scope of this document.

Building an MPEG video, especially for a large event, can take some time and should not be undertaken lightly as the effect on your host box of many CPU intensive encoders will not be good. However once a video has been created for an event it will be kept so subsequent viewing will not incur the generation overhead. Videos can also be included in notification emails, however care should be taken when using this option as for many frequent events the penalty in CPU and disk space can quickly mount up.

Options and Users

The final area covered by the tutorial is the options and user section. If you are running in authenticated mode and don’t have system privileges then you will not see this section at all and if you are running in un-authenticated mode then no user section will be displayed.

The various options you can specify are displayed in a tabbed dialog with each group of options displayed under a different heading. Each option is displayed with its name, a short description and the current value. You can also click on the ‘?’ link following each description to get a fuller explanation about each option. This is the same as you would get from zmconfig.pl. A number of option groups have a master option near the top which enables or disables the whole group so you should be aware of the state of this before modifying options and expecting them to make any difference.

If you have changed the value of an option you should then ‘save’ it. A number of the option groups will then prompt you to let you know that the option(s) you have changed will require a system restart. This is not done automatically in case you will be changing many values in the same session, however once you have made all of your changes you should restart ZoneMinder as soon as possible. The reason for this is that web and some scripts will pick up the new changes immediately but some of the daemons will still be using the old values and this can lead to data inconsistency or loss.

One of the options you may notice in the ‘System’ tab allows you to specify the default language for your installation of ZoneMinder. Versions 1.17.0 and later support multiple languages but rely on users to assist in creating language files for specific languages. To specify a language you will have to give the applicable code, thus for UK English this is en_gb, and for US English it would be en_us, if no language is given then UK English is assumed. Most languages will be specified in this nn_mm format and to check which languages are available look for files named zm_lang_*.php in the ZoneMinder build directory where the parts represented by the ‘*’ would be what you would enter as a language. This is slightly unwieldy and will probably be improved in future to make it easier to determine language availability. On checking which languages are available it may be that your preferred language is not currently included and if this is the case please consider doing a translation and sending it back to it may be included in future releases. All the language elements are given in the zm_lang_en_gb.php file along with a few notes to help you understand the format.

As mentioned above, you may also see a ‘users’ tab in the Options area. In this section you will see a list of the current users defined on the system. You can also add or delete users from here. It is recommended you do not delete the admin user unless you have created another fully privileged user to take over the same role. Each user is defined with a name and password (which is hidden) as well as an enabled setting which you can use to temporarily enable or disable users, for example a guest user for limited time access. As well as that there is a language setting that allows you to define user specific languages. Setting a language here that is different than the system language will mean that when that user logs in they will have the web interface presented in their own language rather than the system default, if it is available. Specifying a language here is done in the same way as for the system default language described above.

There are also five values that define the user permissions, these are ‘Stream’, ‘Events’, ‘Control’, ‘Monitors’ and ‘System’ Each can have values of ‘None’, ‘View’ or ‘Edit’ apart from ‘Stream’ which has no ‘Edit’ setting. These values cover access to the following areas; ‘Stream’ defines whether a user is allowed to view the ‘live’ video feeds coming from the cameras. You may wish to allow a user to view historical events only in which case this setting should be ‘none’. The ‘Events’ setting determines whether a user can view and modify or delete any retained historical events. The ‘Control’ setting allows you to indicate whether the user is able to control any Pan/Tilt/Zoom type cameras you may have on your system. The ‘Monitors’ setting specifies whether a user can see the current monitor settings and change them. Finally the ‘System’ setting determines whether a user can view or modify the system settings as a whole, such as options and users or controlling the running of the system as a whole.

As well as these settings there is also a ‘Bandwidth’ setting which can be used to limit the maximum bandwidth that a user can view at and a ‘Monitor Ids’ setting that can be used for non-’System’ users to restrict them to only being able to access streams, events or monitors for the given monitors ids as a comma separated list with no spaces. If a user with ‘Monitors’ edit privileges is limited to specific monitors here they will not be able to add or delete monitors but only change the details of those they have access to. If a user has ‘System’ privileges then the ‘Monitors Ids’ setting is ignored and has no effect.’

That’s pretty much is it for the tour, though there is a lot more to ZoneMinder as you will discover. You should experiment with the various settings to get the results you think are right for your requirements.

Camera Control

ZoneMinder provides the facility to control cameras from the web interface and to some extent automatically. Pan/Tilt/Zoom (PTZ) cameras have a wide range of capabilities and use a large number of different protocols making any kind of generic control solution potentially very difficult. To address this ZoneMinder uses two key approaches to get around this problem.

Definition of Capabilities 
For each camera model you use, an entry in the camera capabilities table must be created. These indicate what functions the camera supports and ensure that the interface presents only those capabilities that the camera supports. There are a very large number of capabilities that may be supported and it is very important that the entries in this table reflect the actual abilities of the camera. A small number of example capabilities are included in ZoneMinder, these can be used ‘as is’ or modified.
Control Scripts 
ZoneMinder itself does not generally provide the ability to send commands to cameras or receive responses. What it does is mediate motion requests from the web interface into a standard set of commands which are passed to a script defined in the control capability. Example scripts are provided in ZoneMinder which support a number of serial or network protocols but it is likely that for many cameras new scripts will have to be created. These can be modelled on the example ones, or if control commands already exist from other applications, then the script can just act as a ‘glue’ layer between ZoneMinder and those commands.

It should be emphasised that the control and capability elements of ZoneMinder are not intended to be able to support every camera out of the box. Some degree of development is likely to be required for many cameras. This should often be a relatively straightforward task however if you have a camera that you want to be supported then please feel free to get in touch and I should be able to provide an estimate for how much effort this is likely to be. It is also the case that I have only been able to access this limited number of cameras to test against; some other cameras may use different motion paradigms that don’t fit into the control capability/script architecture that ZoneMinder uses. If you come across any cameras like this then please forward as much information to me as possible so that I may be able to extend the ZoneMinder model to encompass them.

Control Capabilities

If you have a camera that supports PTZ controls and wish to use it with ZoneMinder then the first thing you need to do is ensure that it has an accurate entry in the capabilities table. To do this you need to go to the Control tab of the Monitor configuration dialog and select ‘Edit’ where it is listed by the Control Type selection box. This will bring up a new window which lists, with a brief summary, the existing capabilities. To edit an existing capability to modify select the Id or Name of the capability in question, or click on the Add button to add a new control capability. Either of these approaches will create a new window, in familiar style, with tabs along the top and forms fields below. In the case of the capabilities table there are a large number of settings and tabs, the mean and use of these are briefly explained below.

Main Tab

Name 
This is the name of the control capability, it will usually make sense to name capabilities after the camera model or protocol being used.
Type 
Whether the capability uses a local (usually serial) or network control protocol.
Command 
This is the full path to a script or application that will map the standard set of ZoneMinder control commands to equivalent control protocol command. This may be one of the shipped example zmcontrol-*.pl scripts or something else entirely.
Can Wake 
This is the first of the actual capability definitions. Checking this box indicates that a protocol command exists to wake up the camera from a sleeping state.
Can Sleep 
The camera can be put to sleep.
Can Reset 
The camera can be reset to a previously defined state.

Move Tab

Can Move 
The camera is able move, i.e. pan or tilt.
Can Move Diagonally 
The camera can move diagonally. Some devices can move only vertically or horizontally at a time.
Can Move Mapped 
The camera is able internally map a point on an image to a precise degree of motion to centre that point in the image.
Can Move Absolute 
The camera can move to an absolute location.
Can Move Relative 
The camera can more to a relative location, e.g. 7 point left or up.
Can Move Continuous 
The camera can move continuously in a defined direction until told to stop or the movement limits are reached, e.g. left.

Pan Tab

Can Pan 
The camera can pan, or move horizontally.
Min/Max Pan Range 
If the camera supports absolute motion this is the minimum and maximum pan co-ordinates that may be specified, e.g. -100 to 100.
Min/Man Pan Step 
If the camera supports relative motion, this is the minimum and maximum amount of movement that can be specified.
Has Pan Speed 
The camera supports specification of pan speeds.
Min/Max Pan Speed 
The minimum and maximum pan speed supported.
Has Turbo Pan 
The camera supports an additional turbo pan speed.
Turbo Pan Speed 
The actual turbo pan speed.

Tilt Tab

Definition of Tilt capabilities, fields as for ‘Pan’ tab.

Zoom Tab

Can Zoom 
The camera can zoom.
Can Zoom Absolute 
The camera can zoom to an absolute position.
Can Zoom Relative 
The camera can zoom to a relative position.
Can Zoom Continuous 
The camera can zoom continuously in or out until told to stop or the zoom limits are reached.
Min/Max Zoom Range 
If the camera supports absolute zoom this is the minimum and maximum zoom amounts that may be specified.
Min/Man Zoom Step 
If the camera supports relative zoom, this is the minimum and maximum amount of zoom change that can be specified.
Has Zoom Speed 
The camera supports specification of zoom speed.
Min/Max Zoom Speed 
The minimum and maximum zoom speed supported.

Focus Tab

Definition of Focus capabilities, fields as for ‘Zoom’ tab, but with the following additional capability.

Can Auto Focus 
The camera can focus automatically.

White Tab

Definition of White Balance capabilities, fields as for ‘Focus’ tab.

Iris Tab

Definition of Iris Control capabilities, fields as for ‘Focus’ tab.

Presets Tab

Has Presets 
The camera supports preset positions.
Num Presets 
How many presets the camera supports. If the camera supports a huge number of presets then it makes sense to specify a more reasonable number here, 20 or less is recommended.
Has Home Preset 
The camera has a defined ‘home’ position, usually in the mid point of its range.
Can Set Presets 
The camera supports setting preset locations via its control protocol.

Control Scripts

The second key element to controlling cameras with ZoneMinder is ensuring that an appropriate control script or application is present. A small number of sample scripts are included with ZoneMinder and can be used directly or as the basis for development. Control scripts are run atomically, that is to say that one requested action from the web interface results in one execution of the script and no state information is maintained. If your protocol requires state information to be preserved then you should ensure that your scripts do this as ZoneMinder has no concept of the state of the camera in control terms.

If you are writing a new control script then you need to ensure that it supports the parameters that ZoneMinder will pass to it. If you already have scripts or applications that control your cameras, the ZoneMinder control script will just act as glue to convert the parameters passed into a form that your existing application understands. If you are writing a script to support a new protocol then you will need to convert the parameters passed into the script to equivalent protocol commands. If you have carefully defined your control capabilities above then you should only expect commands that correspond to those capabilities.

The standard set of parameters passed to control scripts is defined below,

--device=<device> 
This is the control device from the monitor definition. Absent if no device is specified.
--address=<address> 
This is the control address from the monitor definition. This will usually be a hostname or ip address for network cameras or a simple numeric camera id for other cameras.
--autostop=<timeout> 
This indicates whether an automatic timeout should be applied to stop the given command. It will only be included for continuous commands, as listed below, and will be a timeout in decimal seconds, probably fractional.
--command=<command> 
This specifies the command that the script should execute. Valid commands are given below.
--xcoord=<x>, --ycoord=<y> 
This specifies the x and/or y coordinates for commands which require them. These will normally be absolute or mapped commands.
--width=<width>, --height=<height> 
This specifies the width and height of the current image, for mapped motion commands where the coordinates values passed must have a context.
--speed=<speed> 
This specifies the speed that the command should use, if appropriate.
--panspeed=<speed>, --tiltspeed=<speed> 
This indicates the specific pan and tilt speeds for diagonal movements which may allow a different motion rate for horizontal and vertical components.
--step=<step> 
This specifies the amount of motion that the command should use, if appropriate. Normally used for relative commands only.
--panstep=<step>, --tiltstep=<step> 
This indicates the specific pan and tilt steps for diagonal movements which may allow a different amount of motion for horizontal and vertical components.
--preset=<preset> 
This specifies the particular preset that relevant commands should operate on.

The command option listed above may take one of the following commands as a parameter.

wake 
Wake the camera.
sleep 
Send the camera to sleep.
reset 
Reset the camera.
move_map 
Move mapped to a specified location on the image.
move_pseudo_map 
As move_map above. Pseudo-mapped motion can be used when mapped motion is not supported but relative motion is in which case mapped motion can be roughly approximated by careful calibration.
move_abs_<direction> 
Move to a specified absolute location. The direction element gives a hint to the direction to go but can be omitted. If present it will be one of up, down, left, right, upleft, upright, downleft or downright.
move_rel_<direction> 
Move a specified amount in the given direction.
move_con_<direction> 
Move continuously in the given direction until told to stop.
move_stop 
Stop any motion which may be in progress.
zoom_abs_<direction> 
Zoom to a specified absolute zoom position. The direction element gives a hint to the direction to go but can be omitted. If present it will be one of tele or wide.
zoom_rel_<direction> 
Zoom a specified amount in the given direction.
zoom_con_<direction> 
Zoom continuously in the given direction until told to stop.
zoom_stop 
Stop any zooming which may be in progress.
focus_auto 
Set focusing to be automatic.
focus_man 
Set focusing to be manual.
focus_abs_<direction> 
Focus to a specified absolute focus position. The direction element gives a hint to the direction to go but can be omitted. If present it will be one of near or far.
focus_rel_<direction> 
Focus a specified amount in the given direction.
focus_con_<direction> 
Focus continuously in the given direction until told to stop.
focus_stop 
Stop any focusing which may be in progress.
white_<subcommand> 
As per the focus commands, except that direction may be in or out.
iris_<subcommand> 
As per the focus commands, except that direction may be open or close.
preset_set 
Set the given preset to the current location.
preset_goto 
Move to the given preset.
preset_home 
Move to the home preset.

Mobile Devices

  • After 1.24.x, access to the "light" interface changed to http://xxx.xxx.xxx.xxx/zm/index.php?skin=mobile ; You may find that you have a directory named "skins" under ZoneMinder base dir, so you may use one of the existent skins as a base to adapt to your needs;

Type this in your mobile browser: http://xxx.xxx.xxx.xxx/zm/index.php?format=xhtml (deprecated)

ZoneMinder has always had a minimal WML (Wireless Markup Language) capability to allow it to function on mobile phones and similar devices. However as of 1.20.0 this is now deprecated and has been replaced with a new XHTML – Mobile Profile mode as well as the default HTML4. XHTML-MP is a small, and limited, version of XHTML intended for mobile devices and is based on XHTML Basic. It does not contain scripting or other dynamic elements and essentially is a subset of HTML as most people know it.

The ZoneMinder XHTML-MP interface allows you to log into your installation via your phone or mobile devices and perform a limited number of tasks. These include viewing recent events, and monitoring live streams. However unlike the full interfaces these elements are presented as still images requiring manual refreshing. For now the XHTML-MP interface is presented as a prototype interface; rather than one offering full capabilities. As such, please feel free to make comments or offer suggestions via the forums on http://www.zoneminder.com.

As well as XHTML-MP, ideally I’d like to be able to offer a WML2.0 interface. WML2.0 is a blending of WML1.3, which is traditional WAP, and XHTML. As such it offers the scripting that WML has traditionally included plus the better control of mark-up that is the realm of XHTML. Unfortunately so far I’m unaware of any devices that support WML2.0 even if they say they are WAP2 compliant; certainly I’ve never had a phone that does. If you find out that a particular phone does support this then please let me know (or better still send me the phone!).

If you wish to use the XHTML-MP interface to ZoneMinder there is no extra configuration required to enable it per se. However ZoneMinder needs to be able to figure out what kind of content to deliver to particular browsers, so you have two choices. You can edit zm.php and include a definition that corresponds to your phone, describing a small number of basic capabilities, you will see a couple of examples already there, or you can use the comprehensive open source WURFL package available from http://wurfl.sourceforge.net/. You will need to download both the WURFL php files and the wurfl.xml file itself. WURFL is a resource containing information on the capabilities of a huge number of mobile phones, devices and browsers. Thus once it has matched your phone it can determine various capabilities it may possess. This means that ZoneMinder itself only has to deal with these capabilities and not the individual phone types. If you prefer you can also add the format=xHTML url parameter when you load ZoneMinder to force the xHTML format and skip the automatic determination altoghether.

To use WURFL you should install the php files in the same directory as ZoneMinder and then create a ‘wurfl’ sub-directory and ensure it is readable and writeable (or preferably owned by) your web server user. You should put the wurfl.xml file in there. One other thing you may need to change, as the xml file is quite large, is the ‘memory_limit’ setting in php.ini as the default setting of 8Mb may be too small. Once you’ve done this you should find that your phone or device is recognised and if it can support XHTML-MP it will receive that interface. If your phone is very new, or you are using an old version of the XML file you might find that it is not present however. The WURFL library uses a caching strategy to avoid reloading the whole XML file each time so check if a sensible looking cache file has been created in the ‘wurfl’ sub-directory also check the wurfl.log in the same place.

The WURFL is a third party application and as such I am unable to offer support directly for it. If you feel your device is missing or incorrectly represented please contact the authors via their own channels. If on the other hand you have any comments on ZoneMinder on your device specifically please let me know and I would be pleased to hear about it.

As support for cookies in mobile devices is patchy at best, the groups feature is not fully implemented in the XHTML-MP views. Instead if there is a group called ‘Mobile’ already defined then that group will always be effective, if not then all monitors available to the logged in user will be visible,

Logging

Most components of ZoneMinder can emit informational, warning, error and debug messages in a standard format. These messages can be logged in one or more locations. By default all messages produced by scripts are logged in <script name>.log files which are placed in the directory defined by the ZM_PATH_LOGS configuration variable. This is initially defined as ‘/tmp’ though it can be overridden (see the Options and Users section above). So for example, the zmpkg.pl script will output messages to /tmp/zmpkg.pl, an example of these messages is

03/01/06 13:46:00.166046 zmpkg[11148].INF [Command: start]

where the first part refers to the date and time of the entry, the next section is the name (or an abbreviated version) of the script, followed by the process id in square brackets, a severity code (INF, WAR, ERR or DBG) and the debug text. If you change the location of the log directory, ensure it refers to an existing directory which the web user has permissions to write to. Also ensure that no logs are present in that directory the web user does not have permission to open. This can happen if you run commands or scripts as the root user for testing at some point. If this occurs then subsequent non-privileged runs will fails due to being unable to open the log files.

As well as specific script logging above, information, warning and error messages are logged via the system syslog service. This is a standard component on Linux systems and allows logging of all sorts of messages in a standard way and using a standard format. On most systems, unless otherwise configured, messages produced by ZoneMinder will go to the /var/log/messages file. On some distributions they may end up in another file, but usually still in /var/log. Messages in this file are similar to those in the script log files but differ slightly. For example the above event in the system log file looks like

Jan  3 13:46:00 shuttle52 zmpkg[11148]: INF [Command: start]

where you can see that the date is formatted differently (and only to 1 second precision) and there is an additional field for the hostname (as syslog can operate over a network). As well as ZoneMinder entries in this file you may also see entries from various other system components. You should ensure that your syslogd daemon is running for syslog messages to be correctly handled.

A number of users have asked how to suppress or redirect ZoneMinder messages that are written to this file. This most often occurs due to not wanting other system messages to be overwhelmed and obscured by the ZoneMinder produced ones (which can be quite frequent by default). In order to control syslog messages you need to locate and edit the syslog.conf file on your system. This will often be in the /etc directory. This file allows configuration of syslog so that certain classes and categories of messages are routed to different files or highlighted to a console, or just ignored. Full details of the format of this file is outside the scope of this document (typing ‘man syslog.conf’ will give you more information) but the most often requested changes are easy to implement.

The syslog service uses the concept of priorities and facilities where the former refers to the importance of the message and the latter refers to that part of the system from which it originated. Standard priorities include ‘info’, ‘warning’, ‘err’ and ‘debug’ and ZoneMinder uses these priorities when generating the corresponding class of message. Standard facilities include ‘mail’, ‘cron’ and ‘security’ etc but as well this, there are eight ‘local’ facilities that can be used by machine specific message generators. ZoneMinder produces it’s messages via the ‘local1’ facility.

So armed with the knowledge of the priority and facility of a message, the syslog.conf file can be amended to handle messages however you like.

So to ensure that all ZoneMinder messages go to a specific log file you can add the following line near the top of your syslog.conf file

# Save ZoneMinder messages to zm.log
local1.*                        /var/log/zm/zm.log

which will ensure that all messages produced with the local1 facility are routed to fhe /var/log/zm/zm.log file. However this does not necessarily prevent them also going into the standard system log. To do this you will need to modify the line that determines which messages are logged to this file. This may look something like

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;news.none;authpriv.none;cron.none      /var/log/messages

by default. To remove ZoneMinder messages altogether from this file you can modify this line to look like

*.info;local1.!*;mail.none;news.none;authpriv.none;cron.none     /var/log/messages

which instructs syslog to ignore any messages from the local1 facility. If however you still want warnings and errors to occur in the system log file, you could change it to

*.info;local1.!*;local1.warning;mail.none;news.none;authpriv.none;cron.none     /var/log/messages

which follows the ignore instruction with a further one to indicate that any messages with a facility of local1 and a priority of warning or above should still go into the file.

These recipes are just examples of how you can modify the logging to suit your system, there are a lot of other modifications you could make. If you do make any changes to syslog.conf you should ensure you restart the syslogd process or send it a HUP signal to force it to reread its configuration file otherwise your changes will be ignored.

The discussion of logging above began by describing how scripts produce error and debug messages. The way that the binaries work is slightly different. Binaries generate information, warning and error messages using syslog in exactly the same way as scripts and these messages will be handled identically. However debug output is somewhat different. For the scripts, if you want to enable debug you will need to edit the script file itself and change the DBG_LEVEL constant to have a value of 1. This will then cause debug messages to be written to the <script>.log file as well as the more important messages. Debug messages however are not routed via syslog. Scripts currently only have one level of debug so this will cause any and all debug messages to be generated. Binaries work slightly differently and while you can edit the call to zmDbgInit that is present in every binary’s ‘main’ function to update the initial value of the debug level, there are easier ways.

The simplest way of collecting debug output is to click on the Options link from the main ZoneMinder console view and then go to the Debug tab. There you will find a number of debug options. The first thing you should do is ensure that the ZM_EXTRA_DEBUG setting is switched on. This enables debug generally. The next thing you need to do is select the debug target, level and destination file using the relevant options. Click on the ‘?’ by each option for more information about valid settings. You will need to restart ZoneMinder as a whole or at least the component in question for logging to take effect. When you have finished debugging you should ensure you switch debug off by unchecking the ZM_EXTRA_DEBUG option and restarting ZoneMinder. You can leave the other options as you like as they are ignored if the master debug option is off.

Once you have debug being logged you can modify the level by sending USR1 and USR2 signals to the relevant binary (or binaries) to increase or decrease the level of debug being emitted with immediate effect. This modification will not persist if the binary gets restarted however.

If you wish to run a binary directly from the command line to test specific functionality or scenarios, you can set the ZM_DBG_LEVEL and ZM_DBG_LOG environment variables to set the level and log file of the debug you wish to see, and the ZM_DBG_PRINT environment variable to 1 to output the debug directly to your terminal.

All ZoneMinder logs can now be rotated by logrotate. A sample logrotate config file is shown below.

/var/log/zm/*.log {
    missingok
    notifempty
    sharedscripts
    postrotate
        /usr/local/bin/zmpkg.pl logrot 2> /dev/null > /dev/null || true
    endscript
}

Troubleshooting

Please see the Troubleshooting Page.

To Do

Seeing as ZoneMinder is so young and has kind of evolved rather than being planned there are a bunch of improvements and enhancements still to do, here is just a sample.

  • Perhaps split out devices - I think devices should probably be a separate table and class from monitors. Not critical but would represent a better model.
  • Support multicasting real-time video streaming. Current video streaming methods tend to lag after a while. This is a limitation of a single tcp stream per se I think. Using multicasting would make this more responsive.
  • Support mpeg video as an input. This is easy to pick up if it’s a tcp stream, but a bit more of a pain if it’s over udp.
  • Mouseover help - A bit more help popping up when you mouseover things would be handy. A bit more help full stop actually.
  • Automatic device configuration - Video 4 Linux supports various device queries, it should be possible to get most of the device capability information from the device itself. The zmu utility does this now but it's not yet integrated into the web pages.
  • Extend the API. Well ok it's not really got an API yet but the image data is held in shared memory in a very simple format. In theory you could use the capture daemon to grab the images and other things could read them from memory, or the analysis daemon could read images from elsewhere. Either way this should be done through an API, and would need a library I think. Also the zmu utility could probably do a whole lot more to enable other things to manage when the daemons become active etc. The perl modules in 1.22.0 are a first step in this direction.
  • Allow ZoneMinder to 'train' itself by allowing the user to select events that are considered important and to discard those that should be ignored. ZoneMinder will interpolate, add a bit of magic, and recommend settings that will support this selection automatically thereafter. The hooks for this are already in to some extent.
  • Add sound support to allow a captured audio channel to be associated with a video device. Work on this feature has already begun.
  • Comments - Needs many more, but that's just me I'm hopeless at commenting things out. I'll get round to it soon though honest! You're lucky to even get this document.

Bugs

  • When opening a link to an event etc from a notification email the window that is opened is just a regular browser window and not in the context of a proper ZoneMinder web interface. Thus it comes up too big usually (not a major issue) and also things like 'Delete' don't work as it wants to do things to its parent (which is more of a major issue).
  • The .sock files used by the *nix sockets I suspect may have the odd permission issue now and again. I think everything recovers from it but it needs checking out.

Probably bucket loads more, just fire them at me.

  • X10 support broken see my notes for workaround.

http://www.zoneminder.com/forums/viewtopic.php?t=15792

Non-Bugs

Yes, those are tabs in the indents; I like tabs so don't go changing them to spaces please. Also, yes I like my opening braces on their own line most of the time, what's the point of brackets that don't line up?

Everything else that isn't definitely broken is probably deliberate, or was once anyway.

License

ZoneMinder is released under the GPL, see below.

Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Philip Coombes

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.