ZoneMinder: Linux Home CCTV

ZoneMinder is a video camera security and surveillance solution. It can be used for theft prevention or simple home monitoring.

This project has been in the back of my mind for a long time but I did not see any practical use for this until the recent thefts in the neighbourhood. We do not have very valuable stuff in our home, but still, it couldn’t hurt to have a monitoring system to alert us when someone enters the house uninvited. Also, having a an active camera in the house will mostly advise potential burglars to take another house. A small solution like Motion would not do the trick, I needed something advanced, easy to configure and maintain.

So, how much time did I need to invest to get me a full featured surveillance system? Not too much, actually, it was pretty straightforward.

The setup

1x Linux server
your multimedia server, Raspberry Pi or maybe even your PogoPlug

2x Webcams
1 will do, 2 of them gives you a better feel of all the possibilities. First check the compatibility list.

2x USB active extender cables
Not necessary, but if you don’t want to be restrained by the length of your usb cord you might need active extender cables. Just using a normal USB extension cord will only be frustrating because your webcam will probably not work (or not always) . I bought the BlueRigger devices, very cheap and good quality.

Since my personal server is on the attic it was enough to drill a hole from our living room to the attic, feed the extension cable to the server and plug the first webcam in. I just love Open Source projects where you can drill holes. The other webcam has to guard the server itself ( and again, this is only to test the equipment, a better place would be to guard the front door or something )

The installation

Unfortunately the installation is not a ‘one click’ install. But the ZoneMinder Wiki explains everything in detail for your specific Operating System and it is not overly complicated.

If you’re on a Debian based Linux OS, you would probably have to do the following (to give you an idea that it’s not overly complicated):

open a terminal and install zoneminder via apt-get :
sudo apt-get install zoneminder
You should also add a delay to allow MySQL to start before ZoneMinder, you can do this in various ways, one easy way is by adding a sleep to the ZoneMinder startup:
sudo vi /etc/init.d/zoneminder
start() {
sleep 15
echo -n "Starting $prog: "

create your apache links to the ZoneMinder apache configuration:
ln -s /etc/zm/apache.conf /etc/apache2/conf.d/zoneminder.conf
ln -s /etc/zm/apache.conf /etc/apache2/conf-enabled/zoneminder.conf
acitvate cgi and add the user video to the www-data group
a2enmod cgi
adduser www-data video

restart apache
/etc/init.d/apache2 force-reload or
service apache2 restart
apachectl configtest && apachectl restart

browse to your ZoneMinder install : https://<your server>/zm

From there it is pretty straightforward, add the probed camera’s to the list via ‘Add New Monitor’ :


Give them a function (by clicking on Function) and the cameras will do the rest:



The different functions you can choose from do the following:

None: nothing is recorded, it’s off
Monitor: only live streaming, nothing will be recorded
Modect: recording will start once motion is detected
Record: constant recording, no motion detection
Mocord: constant recording with motion being highlighted
Nodect: Special mode to be used by external triggers

If you want to play with this, be warned about the ‘record‘ function, after initial install I had set my camera’s on ‘record’. Everything worked fine but after a few days I noticed erratic behaviour on my server. After inspecting the server logs it appeared I could no longer write to the disks, “no space left on the device”. There was however plenty of space because I had set the image and video directory to a spare drive dedicated for ZoneMinder. Apparently ZoneMinder spawns a lot of files (especially in constant recording mode) and my server ran out of inode objects … so be careful and set up purging rules.

I’ve set up my camera’s in ‘modect‘, if there is motion, it will record everything. All recordings are immediately viewable by clicking on the number of the events and choose an event you want to watch:




I’ve turned off the light at the end of the recording, it’s a beautiful living room but not something I want to share with everyone 😉
You can watch all entries, fast forward, zoom, pause, etc. Ideal to catch a pesky cookie thief in the kitchen. Zoom in to count the number of cookies stolen.

Now we come to the good part, it’s good to have working camera’s and recordings of all detected motion but there should be ways to trigger something when motion is detected. You can set up ‘filters’ which will trigger an action whenever motion is detected, in my case I’ve tried to set up a script that will play an alarm noise in the living room ( using a set of cheap speakers which directly connect to the audio card ), this to let the possible burglars know that something has noticed their behaviour (this could be enough input to scare them away):


Unfortunately ZoneMinder runs as the www-data user and this user (luckily) does not have the necessary privileges to play audio directly on the server. Luckily I could resort to incron, this works similarly to cron but will trigger a script (as the root user) whenever a file changes in a certain directory. I only needed a ZoneMinder filter that would write a file in a folder whenever motion was detected, another script would be triggered by an incron entry which would start playing the sound file.

But there is more, all alerts can be sent to me by mail by configuring your email details in the options settings and setting this as an instruction for the filter:


A friendly message from my security system pops on my mobile:


An alarm has been detected on your installation of the ZoneMinder.

The details are as follows :-

Monitor : Livingroom
Event Id : 825
Length : 3.49
Frames : 54 (4)
Scores : t15 m7 a3

This alarm was matched by the soundthealarm filter and can be viewed at ?view=event&mode=stream&mid=9&eid=825


So the basic functionality is easy to set up and maintain, all the necessary functionality is there for you to expand, just look at the extensive options window:


There is so much more you can do with ZoneMinder, a few examples (right from the wiki, off course):

  • Supports video, USB and network cameras.
  • Support Pan/Tilt/Zoom cameras, extensible to add new control protocols.
  • Built on standard tools, C++, perl and PHP.
  • Uses high performance MySQL database.
  • High performance independent video capture and analysis daemons allowing high failure redundancy.
  • Multiple Zones (Regions Of Interest) can be defined per camera. Each can have a different sensitivity or be ignored altogether.
  • Large number of configuration options allowing maximum performance on any hardware.
  • User friendly web interface allowing full control of system or cameras as well as live views and event replays.
  • Supports live video in mpeg video, multi-part jpeg and stills formats.
  • Supports event replay in mpeg video, multi-part jpeg, stills formats, along with statistics detail.
  • User defined filters allowing selection of any number of events by combination of characteristics in any order.
  • Event notification by email or SMS including attached still images or video of specific events by filter.
  • Automatic uploading of matching events to external FTP storage for archiving and data security.
  • Includes bi-directional X.10 (home automation protocol) integration allowing X.10 signals to control when video is captured and for motion detection to trigger X.10 devices.
  • Highly partitioned design allow other hardware interfacing protocols to be added easily for support of alarm panels etc.
  • Multiple users and user access levels Multi-language support with many languages already included Full control script support allowing most tasks to be automated or added to other applications.
  • Support external triggering by 3rd party applications or equipment.
  • xHTML mobile/cellular phone access allowing access to common functions
  • iPhone interface available


I could extend our security setup with another set of camera’s, SMS notifications but for now this setup will do just fine.

If you like ZoneMinder please consider donating here
Beer of the week: Piraat Triple

You may also like...

4 Responses

  1. Dwayne La Rose says:

    Thanks for all the great podcasts! I will be sure to keep up with your blog!

  2. dimitri says:

    Hi Dwayne,

    Thanks 🙂


  3. narvf says:

    The funeral song at the end is sad… But hey, you will be posting some stuff here – that’s great. I loved your podcasts. 102 podcasts is very very good result 🙂

  4. dimitri says:

    I should have chosen another song at the end, true 😉
    Thanks for the kind words, I’m preparing another post as we speak 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *