Difference between revisions of "Dummies Guide"

From ZoneMinder Wiki
Jump to navigationJump to search
 
(22 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This is a short guide for using ZM. It's concise, and tells you what you need to know.
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 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/
Line 17: Line 17:
These are the best supported install guides.
These are the best supported install guides.


[[Ubuntu]] or [[Debian]] / Devuan  1.34 is recommended.
[[Ubuntu]] or [[Debian]] / Devuan  1.36 is recommended.


Even numbers (1.34) are stable. Use those. Odd numbers are testing/development (1.35).  
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]
Use 1.34.


==Test out a Camera==
==Test out a Camera==
Line 42: Line 40:
In ZM, IP address, path, port, and Resolution must be correct. Most other fields can be left at defaults.
In ZM, IP address, path, port, and Resolution must be correct. Most other fields can be left at defaults.


If you can view the MJPEG or JPG url in your browser, you will be in good shape. Take that path, and put it into Zoneminder. 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
Use vlc or ffplay like this:
e.g. root:mypass@192.168.1.5/video.mjpg
ffplay http://192.168.1.5/mjpg/video.mjpg
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 latter can vary in what keywords it uses (pwd vs pass vs password) while the former requires no keywords.
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
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
If pass is blank, you type in root:@192.168.1.5


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


==Obtaining more Cameras==
==Obtaining more Cameras==
Line 60: Line 62:
* '''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>).
* '''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. Anything RTSP should use FFMPEG.
* '''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...
And some others...


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


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




===MJPEG===
===MJPEG===
These include [[Arecont Vision]], [[Axis]], Bosch, [[Foscam]], [[Grandstream]], Instar, Messoa, Zavio and others.  
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
The prices scale with features. Old indoor Axis cameras at 480p-720p resolution (no IR) can be found
online easily for $10-30.
online easily for $10-30.
Also see, [[Hardware_Compatibility_List#Single_Board_Computers SBC cameras]].


===RTSP===
===RTSP===
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.
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. .
Note: Users with 1.32+ can use '''H264 passthrough''', which writes the h264 direct to mp4, and saves some CPU usage. .
Line 85: Line 85:
'''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.  
'''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.  
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 ===
=== A note on Analog Cameras ===


If you are upgrading an existing camera installation, you will likely have coaxial cables for the old cameras. These can be used with Zoneminder in either LOCAL, or REMOTE/FFMPEG. LOCAL, via a PCI or PCI-Express card, REMOTE/FFMPEG through a video encoder that takes the analog stream and converts to either MJPG or RTSP. I recommend the latter.  
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]
 
There is no reason to rip out, or ignore old coaxial cables. They are perfectly viable for Zoneminder. They may be a step behind the IP cameras, however they can be used. That being said, customers generally prefer higher res cameras, so you probably should replace them, unless its a low priority area.


I have not worked with HD analog over coax, and I don't recommend it. It is not standardized yet.
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==
==Watching the Cameras==
Line 99: Line 97:
Cameras can be watched from the ZM apache server website and/or ZMNinja.
Cameras can be watched from the ZM apache server website and/or ZMNinja.


Yu 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.
For business customers offer both choices to the customer. Or build something custom if you like.
 
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 notes on refreshing the stream periodically. [[https://wiki.zoneminder.com/Example_Camera_View_HTML]]
[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 notes on refreshing the stream periodically. [[https://wiki.zoneminder.com/Example_Camera_View_HTML]]
Streaming in ZM, does not slow it down, in my experience.


If you embed the URL in an img tag, include http prefix or it wont work.
If you embed the URL in an img tag, include http prefix or it wont work.
Line 118: Line 116:
for instructions regarding multi port.  
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.
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.


=== Quick Example ===
=== Quick Example ===
Line 127: Line 125:


==Recording in Zoneminder==
==Recording in Zoneminder==
The zmc binary handles recording and analysis.
The zmc binary handles recording and analysis (1.36).


You can record everything (good, but no way to find events). You can modect everything (light HDD use, but misses stuff). You can mocord everything (better, but uses HDD, and event list timeline in ZMNinja shows 10 minute segments). But all of these are flawed. Here's what you do: always record two streams per camera. One, the low res stream, is set to modect, with reasonable (but no need to be perfect) settings for detection. Two, the high res stream is set to either record or nodect under linked monitors and uses h264 passthrough.* The hi res compressed stream is saved directly to disk.
You can record everything (good, but no way to find events). You can modect everything (light HDD use, but misses stuff). You can mocord everything (better, but uses HDD, and event list timeline in ZMNinja shows 10 minute segments). But all of these are flawed. Here's what you do: always record two streams per camera. One, the low res stream, is set to mocord/modect, with reasonable (but no need to be perfect) settings for detection. Two, the high res stream is set to either record and uses h264 passthrough.* The hi res compressed stream is saved directly to disk. Decoding and Analysis should be disabled as well in the source menu.
 
See also this link for a way to use a high res stream under analysis with less CPU: 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'''
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'''
Line 140: Line 140:


The strength of zoneminder 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]
The strength of zoneminder 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]
Start with the most sensitive settings, and make them less sensitive until few false alarms are recorded. Night IR detects more false events than daylight. Monitoring for all alarms can easily be done by e.g. <code>$ tail -f /var/log/syslog</code>.
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''' https://wiki.zoneminder.com/How_to_view_recorded_history_from_show_timeline.
Flawless professional systems use hardware motion detectors, as software detection is not perfect. But, these come at a cost - more initial setup and wiring. I have an arduino sketch here: https://forums.zoneminder.com/viewtopic.php?f=9&t=27442 You aren't mil grade probably so just use sensitive zone settings and two streams.
'''Why motion detection?'''
Using modect or mocord 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]] and [[ZMTrigger]] can be setup off of modect alarms (the latter requiring either modect, mocord, or nodect).
'''Any downsides?'''
Zones must be tuned to be sensitive enough to see all events, but not so sensitive as to detect false alarms. This requires work, and is not guaranteed to work 100% even after tweaking. RABBIT HOLE WARNING...


'''Help, I missed an event!?'''
'''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.).
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.




'''4K Cameras'''
'''4K Cameras'''
Mocord on the low res stream, and record on the high res stream. Do NOT use any analysis (zma) on the high res stream. Analysis is where the CPU is eaten up.   
Mocord on the low res stream, and record on the high res stream. Do NOT use any analysis or decoding on the high res stream. Analysis and decoding is where the CPU is eaten up.   




Line 180: Line 165:


*Zones should be as small as possible, and you should use as few zones per monitor, to lower CPU usage.  
*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 1-2 FPS to lower CPU usage. '''IMPORTANT''' (do not limit Max FPS, only analysis).
*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]], beware.  
*Aggressive Modect usage can run into issues with [[PurgeWhenFull]], beware.  
*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".  
*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".  
*You can use external hardware motion sensors via [[ZMTrigger]] over modect, when high reliability / low false alarms is required. More setup cost though.
*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.
*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.
* 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]]
* 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]]
Line 190: Line 175:


When setting up the cameras, here is some advice.
When setting up the cameras, here is some advice.
* Use fuses on the PSU output to the cameras, if using passive POE adaptors (48v poe is recommended though).
* Don't do anything but 48v POE. Passive POE is more trouble than its worth. There are 5 port POE switches, use those.
* Use barrel plug splitters, and use one 12V PSU. (i.e. a barrel plug that is a 1 to 5 splitter). Cameras in my experience use around 200-400mA of current at 12V (400mA is when IR LEDs are on).
* 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).
* 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 sun shines all day may be enough heat.
* 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.


==Troubleshooting==
==Troubleshooting==
Line 216: Line 200:




* 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.
* 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


* I found it helpful to include monitor ID in camera names, as you run into monitor ID in logs often.
* I found it helpful to include monitor ID in camera names, as you run into monitor ID in logs often.
Line 229: Line 213:


* 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] [http://kb.mozillazine.org/Network.http.max-persistent-connections-per-server Network.http.max-persistent-connections-per-server]. This max persistent connections per server must be > 6 in order to see > 6 camera streams.
* 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] [http://kb.mozillazine.org/Network.http.max-persistent-connections-per-server Network.http.max-persistent-connections-per-server]. This max persistent connections per server must be > 6 in order to see > 6 camera streams.
* Adding "< /dev/null" to the ffmpeg path used by ZM might fix some issues. See [https://forums.zoneminder.com/viewtopic.php?f=32&t=23861&p=91771  ZM Forums: Truncated Video Export]
* If you are going to use a BT878 based card, you can 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], Use a ruler, and measure the dimensions in mm, then purchase one on digikey. A heatsink attached to the plastic of the IC, instead of the actual IC die is not ideal, but it will help. EDIT: I'm not sure if this is necessary, in hindsight. Also consider a video encoder instead of a BT878 card (e.g. search auction sites for 1 or 2 or 4 channel video encoder).


* 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.
* 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.
* Make sure the BIOS is set to power on after power fails.
* Set colourspace to 32-bit for a possible performance boost.


* 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.
* 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.
* With larger camera setups (one 10, one >20 cameras) I needed to change the watchdog timer (/usr/bin/zmwatch.pl) from the default of 10 seconds to 30 or 60 seconds in order to avoid periodic drop outs of individual cameras. The cameras would drop, and not return, unless i restarted zoneminder or disabled and enabled that camera. This setting is managed in options - system. If you see dropouts after that, review /usr/bin/zmwatch.pl and insert additional logging. You can also add a hack to the API so that if cameras drop out they are restarted. See documentation of ZM API. For my setups, they typically drop out once a day on specific cameras. Other cameras will never drop out. EDIT: This was because I had poorly supported cameras. Don't buy off brand cameras, or this might happen to you.


* 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.
* 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.
Line 250: Line 226:
[[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]]
[[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]]


* I made a script to watch cameras that drop out, and disable/reenable 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.
* 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.


* 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:  
* 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:  
Line 262: Line 238:
Note that you might want to set nonstandard ports.
Note that you might want to set nonstandard ports.


* run 2k cameras at least. people like flashy things (like birds) and hi res.
* 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.
 
* users seem to like fluid video, so put high fps on low res substream. analysis fps limit to 2. we don't have (asic) hardware yet, so there are limits, but cpu is still pretty powerful.


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


* passthrough on hi res stream obv. watch low res stream live, expand / open window to hi res stream, ideally (custom javascript could do this:todo).
* use zmninja + the website. offer customers both apps. there are also some other apps available. (e.g. possibly zmsquarer).


* 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.


* in most cases, you should replace coax cams with ethernet. customers that are camera happy tend to like hi res, whether its needed or not, and coax is low res.
* 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.


* (optional) configure zmes or good blob detection. you pretty much only will be detecting people in the average business. maybe cars. For extra points, figure out how to assign names to people in zmes.
* 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


==See Also==
==See Also==
Line 297: Line 271:


* https://wiki.zoneminder.com/How_to_view_recorded_history_from_show_timeline
* https://wiki.zoneminder.com/How_to_view_recorded_history_from_show_timeline
* [[LibVNC]] Screen recording in Zoneminder


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

Latest revision as of 22:31, 11 November 2022

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.

Ubuntu or Debian / Devuan 1.36 is recommended.

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

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 always 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.

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

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]

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.

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 notes on refreshing the stream periodically. [[2]]

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.

Quick Example

Example Camera View HTML

Embedding Streaming Video in External Website from Forums

Recording in Zoneminder

The zmc binary handles recording and analysis (1.36).

You can record everything (good, but no way to find events). You can modect everything (light HDD use, but misses stuff). You can mocord everything (better, but uses HDD, and event list timeline in ZMNinja shows 10 minute segments). But all of these are flawed. Here's what you do: always record two streams per camera. One, the low res stream, is set to mocord/modect, with reasonable (but no need to be perfect) settings for detection. Two, the high res stream is set to either record and uses h264 passthrough.* The hi res compressed stream is saved directly to disk. Decoding and Analysis should be disabled as well in the source menu.

See also this link for a way to use a high res stream under analysis with less CPU: 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

  • Linked monitors have from time to time had bugs or configuration gotchas, so for simplicity sake, I use record. HDD space is cheap.

Motion Detection

What's all this motion detection stuff, anyhow?

The strength of zoneminder lies in its motion detection analysis (thus the 'zone' in zoneminder, being the motion detection zones). See: Understanding Zoneminder's Zoning system for Dummies

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.


4K Cameras Mocord on the low res stream, and record on the high res stream. Do NOT use any analysis or decoding on the high res stream. Analysis and decoding is where the CPU is eaten up.


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

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, beware.
  • 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".
  • 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.
  • 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

Hardware Advice

When setting up the cameras, here is some advice.

  • Don't do anything but 48v POE. Passive POE is more trouble than its worth. There are 5 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.

Troubleshooting

  • Watch logs.
  • Use forum search.
  • Use web search.
  • Enable component logs and navigate to /var/log/zm/.
  • # tail -F /var/log/syslog
  • 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
  • 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.

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.
  • 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.

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