Dummies Guide

From ZoneMinder Wiki
Revision as of 22:25, 23 June 2017 by Snake (talk | contribs) (→‎Install)
Jump to navigationJump to search

Install

Use the install guides provided: Zoneminder Wiki: Contents

I've used Trisquel 7.0 and Devuan Jessie ( tris. is based on ubuntu 14.04).

Some install guides omit required dependencies for libvlc. Search forum if you need libvlc.

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

Make sure you add innodb_file_per_table=1 and ensure that the ZM database is InnoDB format, otherwise you may run into the issues described in MySQL. This is probably not needed in current Zoneminder installs ( >1.29) but good to check.

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 old Axis IP Camera. They are well documented and easy to setup. Buy an old one for $10-20. Follow the instructions on either the Zoneminder Hardware compatiblity list, on ispyconnect's url list, or in the user manual for the camera. Any respectable camera will document it's RTSP and MJPG and JPG paths for you to access. ONVIF is also an option to find the paths.


Follow the instructions in the Hardware Compatiblity List for parameters for setting up a camera the first time. If you have an error, look at the logs.

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 e.g. root:mypass@192.168.1.5

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)
  • REMOTE Grab mjpeg stream or rtsp (h264) stream from IP camera on the network
  • FILE Grab a jpeg file somewhere locally and display that (you provide jpeg images that change from somewhere). Can be used in unique ways (i.e. a slide show).
  • FFMPEG and LIBVLC use the respective libraries to pull a stream similar to REMOTE does for RTSP only. It's often recommended to use FFMPEG (in forums), if you are using RTSP.

Analog cameras are limited in resolution (about 704x480px). So called HD Analog cameras are not compatible with ZM, UNLESS the video encoder outputs an RTSP stream (I have not looked into this, but it's likely that some do). In this respect they would be accessed with REMOTE, FFMPEG, or VLC. However analog cameras can use a video encoder to take an analog signal and put it on the ethernet cables via tcp/ip and RTSP or MJPG. More details on this below. After that you have FILE and REMOTE. I have not used FILE for anything but testing. I will cover REMOTE.


REMOTE gives you the option of either RTSP (h264) or MJPG cameras. Both will work.


MJPG

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.

RTSP

These cameras use h264 compression. 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 as you get more resolution. However it's easier to find a 1080p RTSP camera, for $70 vs. an 1080p MJPEG camera, generally.

Note: Exception is feature-h264-videostorage branch. This new branch takes h264 and writes it direct to an .mp4 container. Keep an eye on this branch. It will be merged into the main branch starting with 1.31 supposedly.

Conclusion

Using Remote you must choose either MJPEG, RTSP, or a mix. 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.

Let me state again, 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 20+ cameras, not breaking a sweat. The former reaches a limit at about 10.

In my case, I needed the most affordable HD MJPG cameras, so I searched and settled on the Foscam models. I'd also recommend Axis, if you can afford them. Beware that 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.

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. LOCAL, via a PCI or PCI-Express card, REMOTE through a video encoder that takes the analog stream and converts to either MJPG or RTSP. I recommend the latter.

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.

Also consider investing in HD Analog cameras. However you are on your own here. I have not researched into this. It should be possible to get an HD Analog Video Encoder that will take an HD analog camera and put it on ethernet for Zoneminder to read as an RTSP stream. If you are doing this, beware that you research and try to get one that follows a standard for CCTV HD encoding. Otherwise, you might be at the mercy of one brand.

Watching the Cameras

Cameras can be watched from ZM web server. Montage view is good. See notes section for a hint about > 6 camera setups.

Another way is to 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). It is possible to use FFServer as a server for a website. FFServer (part of FFMPEG project) will take the video feed, and offer it up to clients. I have used FFServer with Zmodopipe.

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.

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

Quick Example

Example Camera View HTML

Recording in Zoneminder

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 (best, but uses HDD). And finally, You can mix it up. I would recommend in small setups, to throw a >1TB HDD in there for videos and set everything to mocord. For larger setups, you will want to customize each camera based on its priority.


Motion Detection=

What's all this motion detection stuff, anyhow?

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

Start with the most sensitive settings, and make them less sensitive until no false alarms are recorded. Night IR detects more false events than daylight. Monitoring for all alarms can easily be done by $ tail -f /var/log/syslog 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. Beware of running into issues with PurgeWhenFull not able to keep up.


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?

The downside of modect is that zones must be tuned to be sensitive enough to see all events, but not so sensitive as to detect false alarms. This requires manual intervention, but carries a benefit, that you can easily identify when events occured (timeline). Zones should be as small as possible, and you should use as few zones per monitor, to lower CPU usage. If you see events with 1 or 2 alarm frames occuring, you can make a background filter to occassionally delete these. Aggressive Modect usage can run into issues with PurgeWhenFull.

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.

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.
  • I found it helpful to name the cameras after the monitor ID 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. Put all cameras on a physically separate network, or use VLANs.
  • 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), therefore I do not recommend using it. Ext4 seems to work well. Older ext2, or ext3 fs can be upgraded to ext4. I'm not really sure ext2 has better performance, even.
  • 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 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 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.
  • Set colourspace to 32-bit for a possible performance boost.
  • Don't set an FPS limit on REMOTE or FFMPEG, or VLC cameras in Zoneminder. The FPS should only to be set at the IP camera itself. 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.

See Also

  • 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 (some #) channel video encoder instead.
  • 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.
  • 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 instead of motion detection. Experience with microcontrollers such as AVRs, Pics, and the Arduino IDE are applicable here.
  • MySQL can require some optimizing, and there are potential gotchas. Though newer releases of Zoneminder may have resolved some of the issues.

Other Users