Dummies Guide

From ZoneMinder Wiki
Revision as of 00:02, 21 May 2016 by Snake (talk | contribs) (Page start)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Install:

Use the guides here: <easy way link>

I recommend trisquel over ubuntu. And I recommend avoiding anything with init daemons that do too much.

Test out a camera:

Once you get that installed, you will want to test out a camera. You can do a webcam, or you can do an Ip camera. See the supported hardware section.

An axis camera is a good test. They are well supported (though expensive for HD models). Buy an old one for $10-20.

It is important to get the resolution right on the cameras when you are setting them up. You don't need to specify frame rate. Leave blank.


Follow the instructions in the supported hardware section for parameters for setting up zm the first time.

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


Obtaining more cameras:

You have a few options here. You can get a webcam connected through usb (local), you can use an ip camera (with options of mjpeg or rtsp)(remote), or you can have some script grab jpg files from somewhere (anywhere) and put them in a local folder, where ZM reads the images into the folder (file).

If you have any sort of a large setup, local and file grabs will not be practical, which leaves ip cameras. You could also use coaxial cable and grab a bt878 video card, but these are limited in resolution, compared to cat6. And not future proof. There's more, but that's a general overview.

So you want IP cameras. What options do you have? Mjpeg or RTSP cameras.


Mjpeg cameras: These include Axis, Foscam, Bosch, Grandstream, Instar, Messoa, Zavio (according to my notes) and other brands. The prices depend wholly on what resolution you want. 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 for when I setup cameras, but there are many vendors with dual MJPEG and RTSP streaming, cameras with 2K HD resolution (IR) and above. But, more pixels == more $$$$. See the supported hardware docs for more details.

Also see, SBC cameras. ArduinoCam, etc. It should be possible to run cameras with a BBB or an arduino that output 1080p JPEG snapshots or stream. I have not yet looked into it. The tools are there.

RTSP cameras: These cameras utilize the proprietary codecs for h264, compressing and streaming them more efficiently. However ZM decodes all incoming video to jpeg files, so it's not efficient. RTSP cameras are a lot easier to find, due maybe to heavy propaganda of h264. These require libvlc, or ffmpeg to convert the video for zoneminder. Same as Mjpeg, the prices go up accordinly as you get more resolution.

By efficiency, this means that the CPU usage will be much higher. This may be less of an issue with newer CPUs as its possible some hardware optimizations have been put in place allowing decoding of h264 to be done through dedicated channels (or so I've read, I don't really know).


Conclusion:

So based on your needs 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 four cameras around your home, then it isn't important. If you want to purchase powerful server hardware, go out and find cameras of any type, assuming they are supported in zm.

In my case, I needed the most affordable HD Mjpeg cameras that I could use, so I searched high and low and settled on the Foscam models. Beware that some of their newer models 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 something like an Axis. Maybe even set something up on a SBC.


Watching the Cameras:

Once you get the cameras setup you will want to monitor them somehow. Zoneminder will be able to monitor the cameras. See this link: <link>

This seems to work with little performance strain on the server CPU.

In my experience, I received 20FPS on a 480p Dlink camera, and 3FPS on a Foscam 9804 which is a 1080p camera. I have been unable to get higher than 3FPS. I have not tweaked much, yet.

Recording in Zoneminder:

If you have enough high resolution cameras you will see your disk space fill up fast. Zm records in 10 minute segments and captures every jpeg. There is no compression of similar frames, no saving data. Every jpeg is captured.

What do you do?

You use a filter which will take recordings from some specified range and create a video for all matches. Then you make a filter that will delete the videos which have already been recorded.

What do you mean filter?

On the zm home console, there is a filter button. Click that, specify the range of videos you want to create videos for, click the checkbox for 'create video for al matches', submit, select it to run in the background, done.

How is it going to make the video?

You can specify parameters in FFMPEG_OUTPUT_OPTIONS in the options of zm. Make sure you are using ffmpeg, not avconv. You also need to specify the path for ffmpeg.


I spent some time hacking it out and I settled on the following path for ffmpeg output options:

-c:v libx264 -preset ultrafast /videosfolder/on/some/path/`date -d "-1 days" +"%Y%m%d-%H%M%S-%N"`.avi < /dev/null

VP9 compresses best, but is much slower to encode. If you have hardware optimized for VP8 or VP9, maybe it will be better.

Here are a couple others I tried, before settling on libx264:

-c:v libx264 -preset fast -crf 38 -vf hqdn3d=8:6:12 -r 1 -f image2 -i %07d.jpg -vcodec libvpx-vp9 -crf 18 -r 25 -q:v 1 /mnt/where/my/videos/go/`date -d "-1 days" +"%Y%m%d-%H%M%S-%N"`.webm -r 1 -f image2 -i %07d.jpg -vcodec libx264 -crf 18 -preset slower

More are on Zoneminder forums.


So with -c:v libx264 -preset ultrafast /videosfolder/on/some/path/`date -d "-1 days" +"%Y%m%d-%H%M%S-%N"`.avi < /dev/null

This works, but puts all videos from all monitors into one folder. The next step was to make script 1 that would take files daily from this folder and put them into subdirectories labeled by the date. Then I made script 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:

<link here>

So I edited zmvideo.pl and was able to get most of the cameras to export to their own folders (WIP). Though I had to edit the ffmpeg output options above to:

-c:v libx264 -preset ultrafast

as now the perl script is managing where the output folders go.

I had to debug when setting up the perl script in order to make it work. Permissions, and watching the /var/log/zm/{zmvideo,zmfilter}.log helped.


Troubleshooting:

The logs are helpful. Web search, and ZM forums also.

If you click, 'component logs' in the options - logs section of zm, you will get log files in the /var/log/zm/ folder.


Note:

Video archival may have been resolved with 1.29. I don't know, as I don't use it.

Some cams will have dual streams (e.g. Hikvision) where one stream can be RTSP and the other Mjpeg. The resolutions may or may not be the same. You can also set stream type for some (in case you want two RTSP streams).

These proprietary cameras are known to casually report to outside IPs. Keep them off the internet. Don't give them internet access. SBCs might be more secure.

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.