Zoneminder on Raspberri PI

The full tutorial is here on https://raspberrytips.com/install-zoneminder-raspberry-pi/

I extracted the commands here for easy copying and pasting and for the case the original version is removed.

in short log in into the raspberry PI running Rasbian. You may use SSH and a terminal:

sudo apt update

install the webserver and the database

sudo apt install apache2 mariadb-server apt-transport-https

now configure the database:

sudo mysql


CREATE DATABASE zm;

CREATE USER 'zoneminder'@'localhost' IDENTIFIED BY '<password>';

GRANT ALL PRIVILEGES ON zm.* TO 'zoneminder'@'localhost';

FLUSH PRIVILEGES;

sudo mysql -uzoneminder -p

use exit to leave

install zoneminder

sudo apt install zoneminder

edit the conf file:

sudo nano /etc/zm/zm.conf

edit the following entries:

ZM_DB_TYPE=mysql


#ZoneMinder database hostname or ip address and optionally port or unix socket

#Acceptable formats include hostname[:port], ip_address[:port], or localhost:unix_socket

ZM_DB_HOST=localhost


#ZoneMinder database name

ZM_DB_NAME=zm


#ZoneMinder database user

ZM_DB_USER=zoneminder


#ZoneMinder database password

ZM_DB_PASS=<yourpassword>

In my case only the ZM_DB_USER and ZM_DB_PASS needed to be changed,.

save the file (CTRL X and confirm)


sudo chgrp -c www-data /etc/zm/zm.conf

sudo mysql -uzoneminder -p<yourpassword> zm < /usr/share/zoneminder/db/zm_create.sql

configure apache

sudo a2enconf zoneminder

sudo a2enmod cgi

sudo service apache2 reload

sudo update-rc.d zoneminder enable

sudo service zoneminder start

sudo service zoneminder status

check if all is OK. leave with exit.

Now check the timezone of your raspberry PI:

sudo raspi-config

Then go into Localization > Change Time Zone

Select the correct time zone and remember it for the next steps. Exit Raspi-config

sudo nano /etc/php/7.4/apache2/php.ini

(7.4 may be 7.5 or other if your version of php is newer)

Find this line:
;date.timezone =

And change it for example with:
date.timezone = Europe/Amsterdam
Use the same as in raspi-config and remove the “;” at the beginning.

sudo service apache2 restart

go to your browser and enter:

http://<IP-ADDRESS-of-the-PI>/zm/

ZoneMinder has a pretty good documentation for the product (that you can find here). For the PI use the Debian tutorial to install it on Raspberry Pi.

For reolink cameras use this source:

rtmp://192.168.178.XXX/bcs/channel0_sub.bcs?channel=0&stream=0&user=admin&password=<your_password>

Entre the correct IP address and your own pasword for the camera. Enter a capture resolution that is the same as in the settings of the reolink camera for the substream. Usually 640-480 or 640-380. If you dont want to record anything and just watch the stream. Change it at the storage TAB in the edit of the camera in Zoneminder.

How to connect zoneminder to Reolink camera's

Connect zoneminder to record motions. Access you reolink admin interface and set the output of your main and substream to the desired quality.

Settings – Recording – Encode

I suggest lowering the fps as this saves a ton of bandwidth. My main stream is 10fps my substream only 7. This is more than enough for my purposes.

Now change the settings in Zoneminder:

For the source path you would normally chose the rtsp streams however the rtmp streams work better.

rtmp://192.168.178.XXX/bcs/channel0_main.bcs?channel=0&stream=0&user=admin&password=<YOURPASSWORD>

Sub Stream:

rtmp://192.168.178.XX/bcs/channel0_sub.bcs?channel=0&stream=1&user=admin&password=<YOURPASSWORD>

change 192.168.178.XX to the I adress of your IP camera

Now why do we need both the sub and the main stream? Zoneminder does image processing to recognize movement and then trigger recordings. Doing this on a 4k stream is VERY CPU intensive and can't be done on a TRaspberry PI 4. So we will setup the sub stream for the motion detection and then trigger the main stream to record this movement.

So first let us setup the sub stream:

Click on “Add” in the Zoneminder Console:

Under General give the camera a recognizable name. For me its "Voordeur-sub"

Set the source type to ffmpeg.

Set the Function to mocord. This allows me to have 24h low resolution recordings of the substream and in turn triggers the main stream to record once motion is actually detected.

On the source tab add the rtmp url for the substream.

Method: TCP

Capture Resolution: Set this to the same resolution you have set on the reolink cam.

For me 640x480 or 640x380 depending of the camera type.

Under storage its important to set the “Video Writer” to h264 passthrough. This will have zoneminder save the camera feed without transcoding, which once again is VERY CPU instensive.

The other tabs are all down to your personal preference.

Click save and check if you can see the video coming from the camera inside ZM.

If so: Good lets continue with the main stream.

Again click on add Camera.

Give it a name. For me this is "Voordeur-main".

Source: Ffmpeg

Function: Nodect.

This is important as only with Nodect will Zoneminder not run analysis on the 4k stream, thus saving your CPU a lot of work.

Linked Monitors: Here select the “Voordeur-Sub” we just set up.

This insures, that motion trigger on the substream will also trigger a recording on the main stream.

On the source tab now add the rtmp url for the main stream.

Method: TCP

Capture Resolution for me is 2560x1440 of 2556x1920 depending on the camera

Under storage its important to set the “Video Writer” to h264 passthrough.

All the rest is again personal preference.

Click save and check if you can access your main stream as well.

If so then you are done with the basics.

Zoneminder will run motion detection on the low quality sub stream, saving you CPU from a lot of work.

A 24h low quality recording of the substream is saved by zoneminder saving you diskspace.

Whenever motion is detected on the substream zoneminder triggers the main stream to also record giving you high quality footage of the event but not filling up you disk with 24h 4k footage.

Orininal post is here:

https://www.reddit.com/r/reolinkcam/comments/jnurzm/adding_reolink_cameras_to_zoneminder_nvr/

For easy refference I collected and adapted these posts here.