Difference between revisions of "Dummies Guide"

From ZoneMinder Wiki
Jump to navigationJump to search
 
(253 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Notes I've recorded as I've learned ZoneMinder.
This is a lot of what I know about surveillance cameras and ZM.


== Install: ==
If you wish to view the full ZM Documentation, I recommend viewing it through the PDF view, as the sphinx website is not efficient and requires javascript. PDF View: https://readthedocs.org/projects/zoneminder/downloads/pdf/stable/
If you want a hard copy, you can order the documentation through a self publishing service like lulu.com


Zoneminder is a powerful tool, but it has a learning curve. The forums are there to answer questions. Search then post if its not already answered.


Use the installation guides provided on the:
On the learning curve: It can be some work (depending on how complex your system is), but you will become a proficient gnulinux sysadmin if you familiarize yourself with ZM and its many features. If you buy an off the shelf DVR you won't learn nearly as much (if anything). Additionally, these skills are valuable for 'any' Unix-based server (DB, website, email server, kiosk, etc).
 
If you are already knowledgeable about unix based computers, then you shouldn't have any trouble.
 
==Install==
 
 
Use the install guides provided by Bbunge on the wiki:
[https://wiki.zoneminder.com/Contents#Installation_Procedure Zoneminder Wiki: Contents]
[https://wiki.zoneminder.com/Contents#Installation_Procedure Zoneminder Wiki: Contents]
These are the best supported install guides.


I've used trisquel and devuan.
[[Debian]] is recommended. Ubuntu always has problems with updates.


Some installation guides omit the required dependencies for libvlc to work. Search forum if you need libvlc.
Even numbers are stable. Use those. Odd numbers are testing/development.  


Here's a guide for using an external HDD: [https://wiki.zoneminder.com/Using_a_dedicated_Hard_Drive Using a dedicated Hard Drive]
Here's a guide for using an external HDD: [https://wiki.zoneminder.com/Using_a_dedicated_Hard_Drive Using a dedicated Hard Drive]


Make sure you add <code>innodb_file_per_table=1</code> and ensure that the ZM database is InnoDB format, otherwise you may run into the issues described in the mysql section.
==Test out a Camera==
 
== Test out a Camera: ==




Once you get ZM installed, you will want to test out a camera.
Once you get ZM installed, you will want to test out a camera.
You can do a webcam, or you can do an IP camera.  
You can do a webcam, or you can do an IP camera.  
See the [https://wiki.zoneminder.com/Hardware_Compatibility_List  Hardware Compatibility LIst]
See the [[Hardware_Compatibility_List]]
 
I recommend you start with an early [[Axis]]. They are well documented and easy to setup.
Old ones go for $10-20. Follow the instructions on either the Zoneminder Hardware compatibility list,
on ispyconnect's url list, or in the user manual for the camera. Any respectable camera will document it's RTSP and MJPEG / JPG paths for you to access. ONVIF is also an option to find the path for RTSP cameras. This is covered in more detail in [[Finding Camera Stream Paths]].
 
 
Follow the instructions in the Hardware Compatibility List for parameters
for setting up a camera the first time. If you have an error, look at the logs. FFMPEG and VLC can be used to test that the streams are valid. e.g. from terminal: ffmpeg -i rtsp://username:password@<ipaddress>:554/path output.mp4 This is faster than using ZM.
 
In ZM, IP address, path, port, and Resolution must be correct. Most other fields can be left at defaults.


An Axis is a good test. They are well supported (though HD is expensive).  
Use vlc or ffplay like this:
Buy an old one for $10-20.  
ffplay http://192.168.1.5/mjpg/video.mjpg
or ffmpeg
ffmpeg -i http://192.168.1.5/mjpg/video.mjpg output.mp4
or
ffplay rtsp://<user>:<pass>@<hostname/ip>:554/axis-media/media.amp?videocodec=h264&resolution=320x240
or
ffprobe rtsp://<user>:<pass>@<hostname/ip>:554/axis-media/media.amp?videocodec=h264
If the camera requires authorization, consult the user manual, or you can try adding the username and password before the ip like so username:password@ipaddress This is an alternative to 192.168.1.5?username=root&pwd=mypass which most guides tell you to do. Both will work, however the former is easier.


If pass is blank, you type in root:@192.168.1.5


Follow the instructions in the Hardware Compatiblity List for parameters
RTSP usually specifies the port and uses rtsp, instead of http. e.g. <code>rtsp://user:password@192.168.1.10:554/somepath</code>
for setting up a camera the first time. If you have an error, look at the logs.


Resolution must be correct. Many other fields can be left at defaults.
==Obtaining more Cameras==


If you can view the MJPEG or JPG url in your browser, you will be in good shape.


== Obtaining more Cameras: ==
In ZoneMinder, when you add a camera, you have a few options:  
* '''LOCAL''' Camera connected directly to computer (webcam, or analog camera thorugh bttv card)(typically /dev/video0)


* '''REMOTE''' (obsolete) Precursor to ffmpeg.


In ZoneMinder, when you add a camera, you have a few options.
* '''FILE''' Grab a jpg file somewhere locally and display that (you provide images that change from anywhere on the filesystem). Can be used in unusual ways (i.e. a slide show, <insert use here>).
* '''LOCAL''' Camera connected directly to computer (webcam, or analog camera thorugh bttv card)
* '''REMOTE''' Grab mjpeg stream or rtsp (h264) stream from IP camera on the network
* '''FILE''' Grab a jpeg file somewhere on the server and display that (you provide jpeg images that change from somewhere)
* '''FFMPEG''' and '''LIBVLC''' use the respective libraries to pull a stream similar to REMOTE does for RTSP only.


Analog cameras are limited in resolution (about 700x400px). So called HD Analog cameras are not compatible with ZM. However analog cameras can use a network encoder to turn an analog stream into an IP Camera RTSP stream.
* '''FFMPEG''' and '''LIBVLC''' use the respective libraries to pull a stream similar to REMOTE does for RTSP only. They can also watch MJPEG streams and the former can loop local video files.
After that you have FILE and REMOTE. I have not used FILE for anything but one off cameras. I will cover REMOTE.


And some others...


'''REMOTE''' gives you the option of either RTSP (h264) or Mjpeg cameras. Both will work.
FFMPEG / LibVLC is recommended. Don't confuse [[LibVNC]] with LibVLC. LibVNC is for recording VNC (i.e. screenrecording).


'''FFMPEG''' has the option of RTSP (h264) or MJPEG streams.


===Mjpeg===
These include Arecont Vision, Axis, Bosch, Foscam, Grandstream, Instar, Messoa, Zavio and others.
The prices scale with features. Old Axis cameras at 480p resolution (no IR) can be found
online easily for $10-50. New Foscams can be purchased at their online store
for $80-130 with 1080p resolution (IR). Above that is beyond my budget. More pixels means higher cost.


Also see, SBC cameras. ArduinoCam, etc. It should be possible to run cameras with
===MJPEG===
a BBB or an arduino that output 1080p JPEG snapshots or stream.
Older cameras from 2000's. E.g.[[Arecont Vision]], [[Axis]], Bosch, [[Foscam]], [[Grandstream]], Instar, Messoa, Zavio and others.  
The tools are there.  
The prices scale with features. Old indoor Axis cameras at 480p-720p resolution (no IR) can be found
online easily for $10-30. These are generally obsolete.


===RTSP===
===RTSP===
These cameras use h264, compressing and streaming
2010's and newer cameras: These cameras use h264 (or h265) compression. They serve it on an RTSP server. h264 means less bytes, so you end up using less HDD space than compared with MJPEG. H264 is recommended when possible.
the feed. However ZM decodes all incoming video to jpeg files,
so it's not optimized. This requires libvlc, or ffmpeg to convert
the video to jpegs for zoneminder. Same as MJPEG, the prices go up
accordingly as you get more resolution. However it's easier
to find a 1080p RTSP camera, for $70 vs. an 1080p MJPEG camera, generally.


Note: [https://forums.zoneminder.com/viewtopic.php?t=25104 Exception is feature-h264-videostorage branch]. This new branch takes h264 and writes it direct to an .mp4 container. I am not familiar with this branch, but it holds some promise. There is much less HDD space utilized with h264.
Note: Users with 1.32+ can use '''H264 passthrough''', which writes the h264 direct to mp4, and saves some CPU usage. .


===Conclusion===
===How Powerful of a Computer to Use===


Based on your needs you must choose either MJPEG, RTSP, or a mix.
High-end server hardware will perform better than desktop, or low end server hardware. I have seen this firsthand between two servers: KFSN4-DRE and the KGPE-D16.  The latter runs ZM with 25+ cameras, not breaking a sweat. The former reaches a limit at about 10. Another limitation is HDD size.  
If you want a high quantity of cameras, it's more efficient
to use all MJPEG cameras. If you have a small number, or If you want to purchase high-end  
server hardware, then it doesn't matter. With powerful enough server hardware, you will be able
to run 10-20 HD cameras of either type without difficulty. In fact, a lot of my CPU usage comes
from compressing the video (optional, see below).  


Let me state again, that '''high-end''' server hardware will perform much better than any desktop mobo, or low end server mobo. I have seen this firsthand between two servers: KFSN4-DRE and the KGPE-D16. The latter runs ZM with 10+ cameras, hardly breaking a sweat. The former reaches a limit at 10.
I currently recommend buying Axis (new is expensive, so you'll probably purchase used), although many do not have IR. This is not a problem, as outdoors IR on cameras attracts spider webs, and external IR is recommended. Another recommended brand is Hikvision. Hikvision can be bought new for a lower price if warranty is an issue (for business clients that can't afford Axis). The cameras work well with ZM, and are configurable without Windows, Otherwise, any respectable name brand camera will work. Look through the hardware compatibility list. Read the user manual before you purchase the camera, and look for the following: Outdoors/indoors, IR/no-IR, Resolution. IR can be supplemented with external appliances. You can also put pesticide on the cameras to deter bugs... (although I wouldn't).


In my case, I needed the most affordable HD MJPEG cameras that I could use, so I searched
=== A note on Analog Cameras ===
high and low and settled on the Foscam models. I'd also recommend used Arecont Vision cameras. Beware that some newer foscams do not have MJPEG streaming, and some firmware have issues with the stream
not working. Read carefully on the foscam forums before purchasing. Or (better) use an SBC.


== Watching the Cameras: ==
There is an option to use a coax to ethernet adapter. You need two pieces. One is the sender, one is the receiver. They may or may not be identical. These allow the use of IP Cameras over coax. Search ebay. Altronix ebridge ones are about $120 for a pair or adapters (you need a pair for each camera). If this is too much money, you may keep the old coax cameras. See: IP Video Encoders [https://wiki.zoneminder.com/Hardware_Compatibility_List#IP_Video_Encoder]. Honestly, just run ethernet if you have a chance. Customers expect HD these days.


Cameras can be watched from ZM web server.
I have not worked with HD analog over coax, and I don't recommend it. I did try to keep old coax cameras but they became obsolete. IP cameras are the way to go.


Another way is to make an html file on a remote machine with the following code embedded. Adjust monitor ID as needed.
==Watching the Cameras==
[https://wiki.zoneminder.com/How_to_stream_from_another_ZoneMinder_installation  How to stream from another ZoneMinder installation]


This seems to work with little performance strain on ZM, from my setup watching 10 1080p cameras.
Cameras can be watched from the ZM apache server website and/or ZMNinja.
(though resolution is less than 1080p in browser).


== Recording in Zoneminder: ==
For business customers offer both choices to the customer. Or build something custom if you like. HTML imagemaps work well.


There are two approaches I use, with recording in Zoneminder. Record everything, and export old videos to a compressed format for safekeeping, or use motion detection and keep only what the HDD can store.  
You can make fully customizable pages i.e. make an html file on a remote machine with the following code embedded in an img tag. Adjust monitor ID as needed.
[https://wiki.zoneminder.com/How_to_stream_from_another_ZoneMinder_installation  How to stream from another ZoneMinder installation]. Also an easy way to embed video in a website (img tag). See [[Dedicated SBC Camera Monitor]] for an example of a computer that only displays the streams. [[https://wiki.zoneminder.com/Example_Camera_View_HTML]] has the HTML code for API/non-API usage.


Though if desired, you can use both.
If you embed the URL in an img tag, include http prefix or it wont work.
<pre>
img width="500px" height="500px" src="http://zmserveripaddress/zm/cgi-bin/nph-zms?mode=jpeg&monitor=#&scale=100&maxfps=5&user=username&pass=password"
</pre>


===Method 1: Recording All & Exporting Videos Hack===
Call it locally:
<pre>
firefox file:///home/username/file.html
</pre>
 
When you have > 6 cameras, you can either use firefox and edit about:config (explained below in guide), or see
https://forums.zoneminder.com/viewtopic.php?t=28168&p=113934#p113934
for instructions regarding multi port.
 
Watch the scale parameter. That can be adjusted for clients with low power CPUs (ARM SBCs) if whole img boxes seem to drop out. Note that scale does require some CPU on the server side.
 
One note: If you have alternative high/low resolution cameras (motion detect on the low res, record on the high res). You might not want customers to view the low res cameras. In this case, make a group of the high res cameras, and set that to be the default view.


If you set cameras to '''Record''' and if you have enough high resolution cameras you will see your disk space fill
=== Embedding ZM in a webpage ===
up fast. ZM records in 10 minute segments and captures every
frame as a jpeg. There is no compression of similar jpegs. Also, higher frame rate means more jpegs, more disk space.


'''How do you avoid filling up the HDD with lots of cameras?'''
[[Example Camera View HTML]]


You hack ZM. Use a filter which will take recordings from a specified
[https://forums.zoneminder.com/viewtopic.php?f=37&t=26982 Embedding Streaming Video in External Website] from Forums
range and create a video for all matches. Then you make a filter
that will delete the events which have already had videos created.


Or alternatively, you use motion detection (see below), recording only
https://wiki.zoneminder.com/External_Live_Stream#Imagemap_of_Cameras - Highly recommended for medium / large installations.
when motion occurs (modect, not mocord).


'''What do you mean filter?'''
==Monitor Settings in Zoneminder==
The zmc binary handles recording and analysis (1.36).


On the zm home console, there is a filter button. Click that, specify the range
    * use full res stream as the source
of videos you want to create videos for, click the checkbox for 'create video for
    * set camera in zm to use passthrough (not decode) (must be h264, not h265).
al matches', submit/save, select it to run in the background, done.
    * set resolution in zm to be lower than the actual stream. if you have a 2,3,or 4K stream,
      set it to somewhere around 320x240 or 640x480. Note that it must be the same aspect ratio (so
      some fraction of the original stream, e.g. 1920x1080 would be 480x270).
    * set analysis fps to 2
    * mode can be modect or mocord. I prefer modect with some exceptions.
    * set the zone similar to the example zone image below.


'''How is it going to make the video?'''
By doing this you will get a low res live view and analysis, but the recorded videos will be full res when watched. This is the easiest way to setup ZM. You can also use linked monitors or have multiple streams, but neither of those options are worth the trouble. Note that there may be a warning in ZM about the stream not matching the resolution but that can be ignored (it is a warning, not an error). This has been discussed on the forums, search there for further details.


You can specify parameters in FFMPEG_OUTPUT_OPTIONS in the
https://forums.zoneminder.com/viewtopic.php?f=10&t=31334&p=124410
options of zm. Make sure you are using ffmpeg, not avconv. You
also need to specify the path for ffmpeg. I used the ffmpeg binary.


In ZM 1.32+, you can use multiple HDs (as many as you like), and assign cameras to where they should be saved. These are '''storage areas'''


==Motion Detection==


'''What's all this motion detection stuff, anyhow?'''


I settled on the following path for ffmpeg
The challenge of all surveillance systems lies in its motion detection analysis (thus the 'zone' in zoneminder, being the motion detection zones). See: [https://wiki.zoneminder.com/Understanding_ZoneMinder%27s_Zoning_system_for_Dummies  Understanding Zoneminder's Zoning system for Dummies]. Zones have their gotchas, and you may want to consider ZMES. Like AI, expect 90% but do not ever expect 100%. You will need hardware motion sensors for 100%.
output options:


<code>
'''Help, I missed an event!?'''
* ''-c:v libx264 -preset ultrafast  /videosfolder/on/some/path/`date -d "-1 days" +"%Y%m%d-%H%M%S-%N"`.avi < /dev/null''
</code>


VP9 compresses best, but is slower to encode. If you have hardware optimized
You can re run analysis on old videos with: https://forums.zoneminder.com/viewtopic.php?f=11&t=24686 and https://forums.zoneminder.com/viewtopic.php?f=8&t=28013&p=109190  You can re-create videos from your (JPEG ONLY) footage, and then reanalyze them. (those with ffmpeg mp4s created, may need to combine the footage into one video, then make that a video source in zm as file.).
for VP8 or VP9, maybe it will be better. Webm / MKV is great.
 
See also: https://forums.zoneminder.com/viewtopic.php?f=11&t=31355 to run zm on files on the server filesystem.
 
 
 
'''Sizing Zones Tip'''
<pre>My first thought is the threshold is too low. It happened to me when I
first started with ZM. I figured out a little trick:
 
Draw a new zone a little smaller than you appear in the video. The zone
will tell you the number of pixels or the percent of the whole frame.
Compare that to the size you have setup to detect. If you are using
percent try changing to pixels, that will not require the math to adjust
the percent.</pre>
ref: http://forums.zoneminder.com/viewtopic.php?f=40&t=30570
 
'''I'm still getting false alerts!'''
 
You may want to run [[ZMES]]. It's not too difficult to setup, but it will require more resources.
See https://wiki.zoneminder.com/ZMES
 
====Example Zone====
[[File:Filters example.png|300px|thumb|right|Basic zone for a 320x240 stream that won't miss events. Though it will still detect false ones without ZMES.]]
Start out with Best, High Sensitivity. Change to pixels instead of percent, and start around 500 (or even 200 depending on whether you are around 640x480 or 320x240). This is a good start, but it may still require [[ZMES]]. For bounding boxes, you should try to use rectangles or squares. I believe someone in the forum mentioned this will save on calculation of the CPU, but regardless, it just looks better. Use the boxes in the bottom to line up X and Y appropriately. See image.
 
===Zone Tips===
 
* Zones should be as small as possible, and you should use as few zones per monitor, to lower CPU usage.
* Analysis FPS can be limited to 2 FPS to lower CPU usage. '''IMPORTANT''' (do not limit Max FPS, only analysis).
* Aggressive Modect usage can run into issues with [[PurgeWhenFull]]
* Transitions from [https://forums.zoneminder.com/viewtopic.php?f=36&t=27141 daylight to IR] cause false alarms. The solution is to "Set a max alarmed area so it doesn't alarm if the whole area is changing" or use ZMES.
* You can use external hardware motion sensors via [[ZMTrigger]] over modect, when high reliability / low false alarms is required. More setup cost / time though.
* JPEG saving, should be avoided on H264 streams when possible. Use H264 passthrough. Consider how decoding the H264 stream to JPEG uses CPU, while passthrough will avoid this conversion step.
* From forum: "In zones, switch to pixels, reduce minimum area/pixels/blobs etc to less than 1000. I find either 500 or 1000 works well."
 
==Hardware Advice==
 
When setting up the cameras, here is some advice.
* Don't do anything but 802.3af POE. Passive POE is more trouble than its worth. There are 5/8 port POE switches, use those.
* If you purchase axis cameras, be aware that the cameras are 5V and the barrel plug is 4.0mm x 1.7mm. It's easiest to use POE on these (and all cameras actually).
* Installing areas where the temperature is high may cause early camera failure (especially for cheaper cameras). Even something as simple as a corner of an enclosed room where the heater runs / sun shines all day may be enough heat. Cameras can be damaged by direct sunlight.
 
==Troubleshooting==


Here are a couple others I found on the forums, before settling on libx264:
<pre>
* ''-c:v libx264 -preset fast -crf 38 -vf hqdn3d=8:6:12


* -r 1 -f image2 -i %07d.jpg -vcodec libvpx-vp9 -crf 18
* Watch logs.


* -r 25 -q:v 1  /mnt/where/my/videos/go/`date -d "-1 days" +"%Y%m%d-%H%M%S-%N"`.webm
* Use forum search.


* -r 1 -f image2 -i %07d.jpg -vcodec libx264 -crf 18 -preset slower''
* Use web search.
</pre>


More are on Zoneminder forums. The general idea is you can specify a codec with
* Enable component logs and navigate to /var/log/zm/.


<code>
* Enable debug logs on a part of ZM, and set path to /var/log/zm/zm_element_debug+ (note you must set the path to /var/log/zm or it will put the debug files in the root home folder.
-c:v libx264
</code>
OR
<code>
-c:v libvpx-vp9
</code>


Find any codec you like, and put it in -c:v and it should encode. Find one your hardware supports well, and go from there.
* <code># tail -F /var/log/syslog</code>


So I used in my FFMPEG_OUTPUT_OPTIONS
* <code># multitail -du -s 5 /var/log/zm/*</code>


<code>
* Beware of underlying hardware faults such as bad RAM.
''-c:v libx264 -preset ultrafast  /videosfolder/on/some/path/`date -d "-1 days" +"%Y%m%d-%H%M%S-%N"`.avi < /dev/null''
</code>


* Disable logs after you are done.


This works, but we have a problem. All videos are in one folder.
==Notes==
The next step was to make script [https://forums.zoneminder.com/viewtopic.php?f=32&t=24799&p=94709#p94709  Script for Deleting Old Exported Video Folders] that would take files daily from this folder
and put them into subdirectories labeled by the date. Then I made script [https://forums.zoneminder.com/viewtopic.php?f=32&t=24799  Script for Deleting Old Exported Video Folders pt.2 ] that would
measure the filesystem capacity of this folder (it is a dedicated drive) and if
the capacity is over a set amount, delete the oldest two days.


This worked well, except that finding videos among the dozens in one day was slow.




The next step was based off of this post:
* Some cams will have two video streams (e.g. Hikvision, Amcrest). The resolutions/video type may or may not be the same. For example, there may be a low resolution mjpeg stream, and a high resolution RTSP stream. Read the data sheet / user manual for cameras you intend to purchase. Multiple streams are desirable. On Axis cameras, you can simply specify the resolution at the end of the path, e.g. &resolution=320x240, (certain model) Foscams have videoMain, and videoSub. There are different variations. One hikvision even had 3(!) streams.


[https://forums.zoneminder.com/viewtopic.php?t=13578  Event Video Saved to Custom Location by Default]
* I found it helpful to include monitor ID in camera names, as you run into monitor ID in logs often.


So I edited zmvideo.pl and was able to get most of the cameras to export to their own
* Proprietary cameras are known to report to outside IPs. Don't give them internet access. Only the server should be wan-accessible. Make a separate network.
folders (see above forum posts). Though now I had to change ffmpeg output options to:


<code>
* Many cameras have default telnet passwords, in addition to the default web access passwords. Change these or keep cameras away from the wan. Cameras are common botnet targets.
''-c:v libx264 -preset ultrafast''
</code>


as now the perl script is managing where the output folders go.
* With server motherboard hardware, you will be able to have more cameras (servers are more powerful, and better servers will have better performance).


I had to debug when setting up the perl script in order to make it work.
* I use ext4 filesystem for the HDDs. I had tried using ext2 filesystem for better performance, but the fsck time is prohibatively slow for ext2 (>24 hours for >2TB). Ext4 seems to work well. Older ext2, or ext3 fs can be upgraded to ext4. Other filesystems are generally, not recommended. Ext4 works fine. You have been warned.
Permissions, and watching the /var/log/zm/{zmvideo,zmfilter}.log helped.


All these steps for "Recording / Exporting Videos" are optional. It is recommended you use Motion Detection or Mocord, for most setups.
* If you have more than 6 cameras you may want to setup multi-port as an alternative to firefox about:config edits. See: https://medium.com/zmninja/multi-port-storage-areas-and-more-d5836a336c93    Note: article written by zm dev. See also [[Multi_Port]]


===Method 2: Motion Detection===
* See [[Multi_Port]]


This is an option most people should use. Use a [https://wiki.zoneminder.com/Using_a_dedicated_Hard_Drive dedicated HDD], record on motion only, and you will retain sufficient history.  
* Edit /etc/default/rcS (applies to devuan/trisquel) and make sure auto FSCK is enabled. Failure to set this, will require manual intervention when the server is repairing the filesystem, requiring you to press a key.


* Make sure the BIOS is set to power on after power fails.


'''What about motion detection'''
* Don't set a Max FPS limit on REMOTE or FFMPEG, or VLC cameras in Zoneminder. The FPS should only to be set at the IP camera itself. Max FPS limiting is for LOCAL cameras, only.


The strength of zoneminder lies in its motion detection (thus the 'zone' in zoneminder, being the motion detection zones). See: [https://wiki.zoneminder.com/Understanding_ZoneMinder%27s_Zoning_system_for_Dummies  Understanding Zoneminder's Zoning system for Dummies]
* Do NOT point cameras at bright light, such as facing a window, a garage door, or anything that generates glare. It will blur the image / potentially damage the camera's image sensor.


Start with the most sensitive settings, and make them less sensitive until no false alarms are recorded. Monitoring for all alarms can easily be done by <code>$ tail -f /var/log/syslog</code> in Devuan based distros. Or you can record everything, if modect isn't working. Mocord will combine both modect and record, having everything recorded, but making a graph where motion occurs (in '''show timeline'''). Mocord is the best, but uses more HDD.
* Buy a set of adapters such as these: to use with your normal 5.5 2.1mm barrel plug. Search multi type 23 or 28 dc power adapter. EDIT: actually only use poe (but picture left as these are useful).


[[File:Universal-28pcs-5-5x2-1mm-Multi-type-Male-Jack-for-DC-Plugs-for-AC-Power-Adapter.jpg 640x640.jpg|200px|Coaxial barrel plug adaptors||Universal 28pcx Multi type Male Jack for DC Plugs]]


'''Is motion detection required?'''
* I made a script to watch cameras that drop out, and disable/re-enable them for my 1.29 setup. See [https://forums.zoneminder.com/viewtopic.php?f=9&t=26909 here]. This also doubles as a notification in case the cameras somehow are powered off. You'll get emails telling you cameras are down. EDIT: See note about poorly supported cameras above. With good cameras, this does not occur. Rabbit hole warning. Stick with quality name brands.


Using modect is '''recommended''' here. Because you are able to click from the main zm index - events - '''show timeline''', and from there quickly review your modect events. Because you save HDD space. And, SMS notifications can be setup off of modect alarms.
* If you are setting up mobile phones with ZMNinja, and the wifi is the same WAN IP as the camera system, setup a VPS with a http/https proxy and point zmninja at the proxy. The proxy can be as simple as:
<pre>
sudo iptables-legacy -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j
DNAT --to-destination <officeip>:80
sudo iptables-legacy -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j
DNAT --to-destination <officeip>:443
sudo iptables-legacy -t nat -A POSTROUTING -j MASQUERADE
</pre>
Note that you might want to set nonstandard ports.


== Troubleshooting: ==
* run 2k cameras at least for business customers. People like hi res. You should have a low res, and a hi res stream. The hi res is record only with no analysis or decoding (using passthrough). The low res is mocord and the one they watch on ZMNinja or the console.


* the more you overbuild the cpu, the faster you can go.


* Watch logs.
* use zmninja + the website. offer customers both apps. there are also some other apps available. (e.g. possibly zmsquarer).


* Use forum search.
* For old coax cameras, buy a coax to ethernet adapter such as the ebridge series by Altronix. These allow use of an ip camera on a coax link. Or, better yet just run ethernet.


* Use web search.
*https://forums.zoneminder.com/viewtopic.php?p=130577&hilit=1.37#p130577 See this note about slow playback in ZM < 1.37.


* If you click, 'component logs' in the options - logs section of zm, you will get log files in the /var/log/zm/ folder.
* For numerous camera setups (10+), you will make your life easier if you deploy all the same model of camera or at least the same resolution. This way you can reuse zone settings across the db.


* <code># tail -F /var/log/syslog</code>
* fine tune zones with scripts on zm  https://forums.zoneminder.com/viewtopic.php?t=31355&p=124557#p124557 make 24 hour sequence, and fix ir false alarms


* Beware of underlying hardware faults such as bad RAM.  
* Always make sure you have a cellphone to test the alignment of the camera. Nothing beats being able to adjust the camera while looking at the feed.


== Notes ==
* Wireguard and remote cameras may need some tuning. Or you can bypass VPNs altogether. https://forums.zoneminder.com/viewtopic.php?p=135840


* If you use ZMNinja, and have the API wan accessible, you may want to consider the security hardening listed on [[ZMNinja]].


* In future ZM It may not be necessary to do the perl hack. The hack is not difficult.
* Video playback performance will always be better via VLC or mpv as opposed to the ZM web interface. Read: https://wiki.zoneminder.com/Filters#Create_Single_Video_of_Multiple_Events


* Some cams will have two video streams (e.g. Hikvision). The resolutions/video type may or may not be the same. For example, there may be a low resolution mjpeg stream, and a high resolution RTSP stream.
==See Also==


* I found it helpful to name the cameras after the monitor ID as you run into monitor ID in logs, often.
* [[API]]


* Proprietary cameras are known to report to outside IPs. Don't give them internet access. Only the server should be wan-accessible.
* [[Cron]] example


* Many cameras have default telnet passwords, in addition to the default web access passwords. Change these or keep cameras away from the wan. Cameras are common botnet targets.
* [[Dedicated SBC Camera Monitor]] Guides for using a Beaglebone Black or Desktop as a client to watch the ZM Server.


* With server motherboard hardware, you will be able to have more cameras (servers are more powerful, and better servers will have better performance).
* [[Docker]]


* I use ext4 filesystem for the HDDs. I had tried using ext2 filesystem for better performance, but the fsck time is prohibatively slow for ext2 (>24 hours for >2TB), therefore I do not recommend using it. Ext4 seems to work well. Older ext2, or ext3 fs can be upgraded to ext4.
* [[External Live Stream]] A quick html file you can deploy on clients to watch the server.


* When viewing the cameras in Firefox, once you get more than 6 cameras from ZM on the browser Firefox will not display the seventh. This is due to a limit of Firefox and can be adjusted in about:config. See: [https://forums.zoneminder.com/viewtopic.php?f=32&t=23417&p=89249  ZM Forums: Problems when two people are watching live]
* [[Exporting Videos Hack]] (not recommended)


* Adding "< /dev/null" to the ffmpeg path used by ZM seems to fix some issues. See [https://forums.zoneminder.com/viewtopic.php?f=32&t=23861&p=91771  ZM Forums: Truncated Video Export]
* [[Filters]] Examples


* If you are going to use a BT878 based card, you probably should add a heatsink onto the top of all *878 chips. This has been mentioned in the [https://forums.zoneminder.com/search.php?keywords=heatsink+bt878 forums in various spots], and I noticed one of my chips out of the 3 on the board not working correctly after the first test. A heatsink with similar dimensions can be purchased from electronic stores such as digikey, mouser, adafruit, or sparkfun. Use a caliper or a ruler, and measure the dimensions in mm, then search for a similar heatsink. You will also need some kind of adhesive. I used an epoxy based thermal adhesive.
* [[Finding Camera Stream Paths]]


* [[Zmodopipe]] Is a tool that can tie an analog DVR system to Zoneminder, although it is far from perfect. I have documented it there, and recommend purchasing an analog network converter instead.
* [[ffmpeg]] Example usage, and notes.


* https://wiki.zoneminder.com/How_to_view_recorded_history_from_show_timeline


=== MYSQL ===
* [[LibVNC]] Screen recording in Zoneminder


* [[Multi_Port]] For streaming more than 6 cameras at once to a browser.


====IBData files Large====
* [[MySQL]] can require some optimizing, and there are potential gotchas. Though newer releases of Zoneminder may have resolved some of the issues.
I had an issue with the ibdata1 file in /var/lib/mysql/ growing too large. It includes some database information and in my 10GB root partition, was taking up 8GB.  


The solutions I found were:
* [[PurgeWhenFull]] requires configuration on larger systems, or systems where events are created at a pace faster than PurgeWhenFull can keep up. Failure to do so, will result in all events being blank, and you will have to fix it.


* ''backup zm database, delete zm db, delete ibdata file, then restore database'' [http://stackoverflow.com/questions/3456159/how-to-shrink-purge-ibdata1-file-in-mysql  How to Shrink/Purge Ibdata1 file]
* [[SMS Notifications]] or email.


OR
* [[Zmodopipe]] Is a tool that can tie an analog DVR system to Zoneminder, although it is far from perfect. I have documented it there, and recommend purchasing a (some #) channel video encoder instead.


* ''Move the ibdata file to another partition''
* [[ZMNinja]] - General usage, also Geoblocking w/apache.


OR
* [[ZMTrigger]] is a tool that can be used to take outside information and overlay it onto the camera display. For example, you might take the temperature, or wind speed, and overlay it on a camera. It can also be used as external motion detection. Experience with electronics and microcontrollers such as AVRs, Pics, and the Arduino IDE are applicable here.


* ''Change DB type to InnoDB (requires backup, deletion, and restoring db, per first solution)''
===Other Users===


Changing the database type to have an innodb file per each table as mentioned in the "how to shrink purge ibdata1 file in mysql" link will keep less data used in the ibdata1 file in the future, allowing the former to be deleted when not needed. On the other hand the ibdata file by default, will not shrink, ever. This may not be an issue in MariaDB.
* [[How to share an USB camera from a remote ZM server to another ZM Server]]


Looking for the least invasive procedure, I went with moving /var/lib/mysql, and adding the optional my.cnf parameter. This required the following tricks (may only apply to Ubuntu 14.04).
* [[General Notes]]


There are a number of guides on moving Mysql, yet many of them omit adding the alias to apparmors settings. This is required. Failing to do so will result in "Job failed to start" when mysql is run with <code>#service mysql start</code>.
* https://forums.zoneminder.com/viewtopic.php?f=32&t=23815&hilit=i+run+this+script+every+night Backup DB script (Recommended)


A guide that covers all the steps required to move mysql on Ubuntu Trusty without omitting anything is here: [http://askubuntu.com/questions/137424/moving-mysql-datadir  Ask Ubuntu: Moving Mysql datadir]
* https://wiki.zoneminder.com/Ubuntu_Install_ZoneMinder_on_Ubuntu_Server Apache Hardening
Note that within my mysql installation there was no socket file in /var/lib or in my.cnf.


====Backup/Restore Mysql DB====
* https://github.com/lbdc/zm_movie_bootstrap Create timelapse videos (adjust fps) or just export. Terminal or GUI. Good example of a basic ZM hack interfacing with db, and querying video files.


After moving the Data directory, I ended up backing up the zm db and restoring it anyways, in order to get the ibdata files to split correctly. This is not hard to do. The only DB you need to mysqldump from a stock ZM installation is the ZM db. And it's also the only DB you need restore.
* [[AxisMotionDetection]] - for offloading motion detection on Axis cameras and using ZMTrigger to receive the alerts (will save CPU).


For a full walkthrough on converting a MyISAM DB to InnoDB  (also covers backing up ZM DB) see [https://wiki.zoneminder.com/Enable_and_convert_MySQL_to_innodb_file_per_table_for_Zoneminder Enable and convert MySQL to innodb file per table for Zoneminder].
* https://forums.zoneminder.com/viewtopic.php?p=131662#p131662 - URL for users to login to.


=== SMS Notifications ===
* https://forums.zoneminder.com/viewtopic.php?t=31005&start=15 - Run cameras at low res, yet using passthrough to get full res with modect on the low res stream and live.


For SMS notifications, setup run states, and define filters which send emails to an [https://en.wikipedia.org/wiki/SMS_gateway SMS gateway] which will forward to your mobile. Use different run states, for turning the SMS notifications off and on. See the following:
* https://forums.zoneminder.com/viewtopic.php?t=31355 - Rerun a video through the zones to tune them.


* [http://zoneminder.readthedocs.io/en/latest/faq.html#how-can-i-get-zm-to-do-different-things-at-different-times-of-day-or-week ZM FAQ: How can I get ZM to do different things at different times of day or week]
[[Category:Dummies_Guide]]
* [http://wiki.zoneminder.com/Instant_Notification Instant Notification]
* [https://forums.zoneminder.com/viewtopic.php?f=34&t=24385 Email Events When Zone Triggered, SMS When Different Zone Triggered]
* [https://forums.zoneminder.com/viewtopic.php?f=34&t=25029 Event notifications do not work]

Latest revision as of 21:55, 31 October 2024

This is a lot of what I know about surveillance cameras and ZM.

If you wish to view the full ZM Documentation, I recommend viewing it through the PDF view, as the sphinx website is not efficient and requires javascript. PDF View: https://readthedocs.org/projects/zoneminder/downloads/pdf/stable/ If you want a hard copy, you can order the documentation through a self publishing service like lulu.com

Zoneminder is a powerful tool, but it has a learning curve. The forums are there to answer questions. Search then post if its not already answered.

On the learning curve: It can be some work (depending on how complex your system is), but you will become a proficient gnulinux sysadmin if you familiarize yourself with ZM and its many features. If you buy an off the shelf DVR you won't learn nearly as much (if anything). Additionally, these skills are valuable for 'any' Unix-based server (DB, website, email server, kiosk, etc).

If you are already knowledgeable about unix based computers, then you shouldn't have any trouble.

Install

Use the install guides provided by Bbunge on the wiki: Zoneminder Wiki: Contents These are the best supported install guides.

Debian is recommended. Ubuntu always has problems with updates.

Even numbers are stable. Use those. Odd numbers are testing/development.

Here's a guide for using an external HDD: Using a dedicated Hard Drive

Test out a Camera

Once you get ZM installed, you will want to test out a camera. You can do a webcam, or you can do an IP camera. See the Hardware_Compatibility_List

I recommend you start with an early Axis. They are well documented and easy to setup. Old ones go for $10-20. Follow the instructions on either the Zoneminder Hardware compatibility list, on ispyconnect's url list, or in the user manual for the camera. Any respectable camera will document it's RTSP and MJPEG / JPG paths for you to access. ONVIF is also an option to find the path for RTSP cameras. This is covered in more detail in Finding Camera Stream Paths.


Follow the instructions in the Hardware Compatibility List for parameters for setting up a camera the first time. If you have an error, look at the logs. FFMPEG and VLC can be used to test that the streams are valid. e.g. from terminal: ffmpeg -i rtsp://username:password@<ipaddress>:554/path output.mp4 This is faster than using ZM.

In ZM, IP address, path, port, and Resolution must be correct. Most other fields can be left at defaults.

Use vlc or ffplay like this:

ffplay http://192.168.1.5/mjpg/video.mjpg
or ffmpeg
ffmpeg -i http://192.168.1.5/mjpg/video.mjpg output.mp4
or
ffplay rtsp://<user>:<pass>@<hostname/ip>:554/axis-media/media.amp?videocodec=h264&resolution=320x240
or 
ffprobe rtsp://<user>:<pass>@<hostname/ip>:554/axis-media/media.amp?videocodec=h264

If the camera requires authorization, consult the user manual, or you can try adding the username and password before the ip like so username:password@ipaddress This is an alternative to 192.168.1.5?username=root&pwd=mypass which most guides tell you to do. Both will work, however the former is easier.

If pass is blank, you type in root:@192.168.1.5

RTSP usually specifies the port and uses rtsp, instead of http. e.g. rtsp://user:password@192.168.1.10:554/somepath

Obtaining more Cameras

In ZoneMinder, when you add a camera, you have a few options:

  • LOCAL Camera connected directly to computer (webcam, or analog camera thorugh bttv card)(typically /dev/video0)
  • REMOTE (obsolete) Precursor to ffmpeg.
  • FILE Grab a jpg file somewhere locally and display that (you provide images that change from anywhere on the filesystem). Can be used in unusual ways (i.e. a slide show, <insert use here>).
  • FFMPEG and LIBVLC use the respective libraries to pull a stream similar to REMOTE does for RTSP only. They can also watch MJPEG streams and the former can loop local video files.

And some others...

FFMPEG / LibVLC is recommended. Don't confuse LibVNC with LibVLC. LibVNC is for recording VNC (i.e. screenrecording).

FFMPEG has the option of RTSP (h264) or MJPEG streams.


MJPEG

Older cameras from 2000's. E.g.Arecont Vision, Axis, Bosch, Foscam, Grandstream, Instar, Messoa, Zavio and others. The prices scale with features. Old indoor Axis cameras at 480p-720p resolution (no IR) can be found online easily for $10-30. These are generally obsolete.

RTSP

2010's and newer cameras: These cameras use h264 (or h265) compression. They serve it on an RTSP server. h264 means less bytes, so you end up using less HDD space than compared with MJPEG. H264 is recommended when possible.

Note: Users with 1.32+ can use H264 passthrough, which writes the h264 direct to mp4, and saves some CPU usage. .

How Powerful of a Computer to Use

High-end server hardware will perform better than desktop, or low end server hardware. I have seen this firsthand between two servers: KFSN4-DRE and the KGPE-D16. The latter runs ZM with 25+ cameras, not breaking a sweat. The former reaches a limit at about 10. Another limitation is HDD size.

I currently recommend buying Axis (new is expensive, so you'll probably purchase used), although many do not have IR. This is not a problem, as outdoors IR on cameras attracts spider webs, and external IR is recommended. Another recommended brand is Hikvision. Hikvision can be bought new for a lower price if warranty is an issue (for business clients that can't afford Axis). The cameras work well with ZM, and are configurable without Windows, Otherwise, any respectable name brand camera will work. Look through the hardware compatibility list. Read the user manual before you purchase the camera, and look for the following: Outdoors/indoors, IR/no-IR, Resolution. IR can be supplemented with external appliances. You can also put pesticide on the cameras to deter bugs... (although I wouldn't).

A note on Analog Cameras

There is an option to use a coax to ethernet adapter. You need two pieces. One is the sender, one is the receiver. They may or may not be identical. These allow the use of IP Cameras over coax. Search ebay. Altronix ebridge ones are about $120 for a pair or adapters (you need a pair for each camera). If this is too much money, you may keep the old coax cameras. See: IP Video Encoders [1]. Honestly, just run ethernet if you have a chance. Customers expect HD these days.

I have not worked with HD analog over coax, and I don't recommend it. I did try to keep old coax cameras but they became obsolete. IP cameras are the way to go.

Watching the Cameras

Cameras can be watched from the ZM apache server website and/or ZMNinja.

For business customers offer both choices to the customer. Or build something custom if you like. HTML imagemaps work well.

You can make fully customizable pages i.e. make an html file on a remote machine with the following code embedded in an img tag. Adjust monitor ID as needed. How to stream from another ZoneMinder installation. Also an easy way to embed video in a website (img tag). See Dedicated SBC Camera Monitor for an example of a computer that only displays the streams. [[2]] has the HTML code for API/non-API usage.

If you embed the URL in an img tag, include http prefix or it wont work.

img width="500px" height="500px" src="http://zmserveripaddress/zm/cgi-bin/nph-zms?mode=jpeg&monitor=#&scale=100&maxfps=5&user=username&pass=password"

Call it locally:

firefox file:///home/username/file.html

When you have > 6 cameras, you can either use firefox and edit about:config (explained below in guide), or see https://forums.zoneminder.com/viewtopic.php?t=28168&p=113934#p113934 for instructions regarding multi port.

Watch the scale parameter. That can be adjusted for clients with low power CPUs (ARM SBCs) if whole img boxes seem to drop out. Note that scale does require some CPU on the server side.

One note: If you have alternative high/low resolution cameras (motion detect on the low res, record on the high res). You might not want customers to view the low res cameras. In this case, make a group of the high res cameras, and set that to be the default view.

Embedding ZM in a webpage

Example Camera View HTML

Embedding Streaming Video in External Website from Forums

https://wiki.zoneminder.com/External_Live_Stream#Imagemap_of_Cameras - Highly recommended for medium / large installations.

Monitor Settings in Zoneminder

The zmc binary handles recording and analysis (1.36).

   * use full res stream as the source
   * set camera in zm to use passthrough (not decode) (must be h264, not h265).
   * set resolution in zm to be lower than the actual stream. if you have a 2,3,or 4K stream, 
     set it to somewhere around 320x240 or 640x480. Note that it must be the same aspect ratio (so 
     some fraction of the original stream, e.g. 1920x1080 would be 480x270).
   * set analysis fps to 2
   * mode can be modect or mocord. I prefer modect with some exceptions.
   * set the zone similar to the example zone image below.

By doing this you will get a low res live view and analysis, but the recorded videos will be full res when watched. This is the easiest way to setup ZM. You can also use linked monitors or have multiple streams, but neither of those options are worth the trouble. Note that there may be a warning in ZM about the stream not matching the resolution but that can be ignored (it is a warning, not an error). This has been discussed on the forums, search there for further details.

https://forums.zoneminder.com/viewtopic.php?f=10&t=31334&p=124410

In ZM 1.32+, you can use multiple HDs (as many as you like), and assign cameras to where they should be saved. These are storage areas

Motion Detection

What's all this motion detection stuff, anyhow?

The challenge of all surveillance systems lies in its motion detection analysis (thus the 'zone' in zoneminder, being the motion detection zones). See: Understanding Zoneminder's Zoning system for Dummies. Zones have their gotchas, and you may want to consider ZMES. Like AI, expect 90% but do not ever expect 100%. You will need hardware motion sensors for 100%.

Help, I missed an event!?

You can re run analysis on old videos with: https://forums.zoneminder.com/viewtopic.php?f=11&t=24686 and https://forums.zoneminder.com/viewtopic.php?f=8&t=28013&p=109190 You can re-create videos from your (JPEG ONLY) footage, and then reanalyze them. (those with ffmpeg mp4s created, may need to combine the footage into one video, then make that a video source in zm as file.).

See also: https://forums.zoneminder.com/viewtopic.php?f=11&t=31355 to run zm on files on the server filesystem.


Sizing Zones Tip

My first thought is the threshold is too low. It happened to me when I 
first started with ZM. I figured out a little trick:

Draw a new zone a little smaller than you appear in the video. The zone 
will tell you the number of pixels or the percent of the whole frame. 
Compare that to the size you have setup to detect. If you are using 
percent try changing to pixels, that will not require the math to adjust 
the percent.

ref: http://forums.zoneminder.com/viewtopic.php?f=40&t=30570

I'm still getting false alerts!

You may want to run ZMES. It's not too difficult to setup, but it will require more resources. See https://wiki.zoneminder.com/ZMES

Example Zone

Basic zone for a 320x240 stream that won't miss events. Though it will still detect false ones without ZMES.

Start out with Best, High Sensitivity. Change to pixels instead of percent, and start around 500 (or even 200 depending on whether you are around 640x480 or 320x240). This is a good start, but it may still require ZMES. For bounding boxes, you should try to use rectangles or squares. I believe someone in the forum mentioned this will save on calculation of the CPU, but regardless, it just looks better. Use the boxes in the bottom to line up X and Y appropriately. See image.

Zone Tips

  • Zones should be as small as possible, and you should use as few zones per monitor, to lower CPU usage.
  • Analysis FPS can be limited to 2 FPS to lower CPU usage. IMPORTANT (do not limit Max FPS, only analysis).
  • Aggressive Modect usage can run into issues with PurgeWhenFull
  • Transitions from daylight to IR cause false alarms. The solution is to "Set a max alarmed area so it doesn't alarm if the whole area is changing" or use ZMES.
  • You can use external hardware motion sensors via ZMTrigger over modect, when high reliability / low false alarms is required. More setup cost / time though.
  • JPEG saving, should be avoided on H264 streams when possible. Use H264 passthrough. Consider how decoding the H264 stream to JPEG uses CPU, while passthrough will avoid this conversion step.
  • From forum: "In zones, switch to pixels, reduce minimum area/pixels/blobs etc to less than 1000. I find either 500 or 1000 works well."

Hardware Advice

When setting up the cameras, here is some advice.

  • Don't do anything but 802.3af POE. Passive POE is more trouble than its worth. There are 5/8 port POE switches, use those.
  • If you purchase axis cameras, be aware that the cameras are 5V and the barrel plug is 4.0mm x 1.7mm. It's easiest to use POE on these (and all cameras actually).
  • Installing areas where the temperature is high may cause early camera failure (especially for cheaper cameras). Even something as simple as a corner of an enclosed room where the heater runs / sun shines all day may be enough heat. Cameras can be damaged by direct sunlight.

Troubleshooting

  • Watch logs.
  • Use forum search.
  • Use web search.
  • Enable component logs and navigate to /var/log/zm/.
  • Enable debug logs on a part of ZM, and set path to /var/log/zm/zm_element_debug+ (note you must set the path to /var/log/zm or it will put the debug files in the root home folder.
  • # tail -F /var/log/syslog
  • # multitail -du -s 5 /var/log/zm/*
  • Beware of underlying hardware faults such as bad RAM.
  • Disable logs after you are done.

Notes

  • Some cams will have two video streams (e.g. Hikvision, Amcrest). The resolutions/video type may or may not be the same. For example, there may be a low resolution mjpeg stream, and a high resolution RTSP stream. Read the data sheet / user manual for cameras you intend to purchase. Multiple streams are desirable. On Axis cameras, you can simply specify the resolution at the end of the path, e.g. &resolution=320x240, (certain model) Foscams have videoMain, and videoSub. There are different variations. One hikvision even had 3(!) streams.
  • I found it helpful to include monitor ID in camera names, as you run into monitor ID in logs often.
  • Proprietary cameras are known to report to outside IPs. Don't give them internet access. Only the server should be wan-accessible. Make a separate network.
  • Many cameras have default telnet passwords, in addition to the default web access passwords. Change these or keep cameras away from the wan. Cameras are common botnet targets.
  • With server motherboard hardware, you will be able to have more cameras (servers are more powerful, and better servers will have better performance).
  • I use ext4 filesystem for the HDDs. I had tried using ext2 filesystem for better performance, but the fsck time is prohibatively slow for ext2 (>24 hours for >2TB). Ext4 seems to work well. Older ext2, or ext3 fs can be upgraded to ext4. Other filesystems are generally, not recommended. Ext4 works fine. You have been warned.
  • Edit /etc/default/rcS (applies to devuan/trisquel) and make sure auto FSCK is enabled. Failure to set this, will require manual intervention when the server is repairing the filesystem, requiring you to press a key.
  • Make sure the BIOS is set to power on after power fails.
  • Don't set a Max FPS limit on REMOTE or FFMPEG, or VLC cameras in Zoneminder. The FPS should only to be set at the IP camera itself. Max FPS limiting is for LOCAL cameras, only.
  • Do NOT point cameras at bright light, such as facing a window, a garage door, or anything that generates glare. It will blur the image / potentially damage the camera's image sensor.
  • Buy a set of adapters such as these: to use with your normal 5.5 2.1mm barrel plug. Search multi type 23 or 28 dc power adapter. EDIT: actually only use poe (but picture left as these are useful).

Universal 28pcx Multi type Male Jack for DC Plugs

  • I made a script to watch cameras that drop out, and disable/re-enable them for my 1.29 setup. See here. This also doubles as a notification in case the cameras somehow are powered off. You'll get emails telling you cameras are down. EDIT: See note about poorly supported cameras above. With good cameras, this does not occur. Rabbit hole warning. Stick with quality name brands.
  • If you are setting up mobile phones with ZMNinja, and the wifi is the same WAN IP as the camera system, setup a VPS with a http/https proxy and point zmninja at the proxy. The proxy can be as simple as:
sudo iptables-legacy -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j 
DNAT --to-destination <officeip>:80
sudo iptables-legacy -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j 
DNAT --to-destination <officeip>:443
sudo iptables-legacy -t nat -A POSTROUTING -j MASQUERADE

Note that you might want to set nonstandard ports.

  • run 2k cameras at least for business customers. People like hi res. You should have a low res, and a hi res stream. The hi res is record only with no analysis or decoding (using passthrough). The low res is mocord and the one they watch on ZMNinja or the console.
  • the more you overbuild the cpu, the faster you can go.
  • use zmninja + the website. offer customers both apps. there are also some other apps available. (e.g. possibly zmsquarer).
  • For old coax cameras, buy a coax to ethernet adapter such as the ebridge series by Altronix. These allow use of an ip camera on a coax link. Or, better yet just run ethernet.
  • For numerous camera setups (10+), you will make your life easier if you deploy all the same model of camera or at least the same resolution. This way you can reuse zone settings across the db.
  • Always make sure you have a cellphone to test the alignment of the camera. Nothing beats being able to adjust the camera while looking at the feed.
  • If you use ZMNinja, and have the API wan accessible, you may want to consider the security hardening listed on ZMNinja.

See Also

  • ffmpeg Example usage, and notes.
  • LibVNC Screen recording in Zoneminder
  • Multi_Port For streaming more than 6 cameras at once to a browser.
  • MySQL can require some optimizing, and there are potential gotchas. Though newer releases of Zoneminder may have resolved some of the issues.
  • PurgeWhenFull requires configuration on larger systems, or systems where events are created at a pace faster than PurgeWhenFull can keep up. Failure to do so, will result in all events being blank, and you will have to fix it.
  • Zmodopipe Is a tool that can tie an analog DVR system to Zoneminder, although it is far from perfect. I have documented it there, and recommend purchasing a (some #) channel video encoder instead.
  • ZMNinja - General usage, also Geoblocking w/apache.
  • ZMTrigger is a tool that can be used to take outside information and overlay it onto the camera display. For example, you might take the temperature, or wind speed, and overlay it on a camera. It can also be used as external motion detection. Experience with electronics and microcontrollers such as AVRs, Pics, and the Arduino IDE are applicable here.

Other Users

  • AxisMotionDetection - for offloading motion detection on Axis cameras and using ZMTrigger to receive the alerts (will save CPU).