Raspberry Pi 4 - Raspbian

From ZoneMinder Wiki
Revision as of 22:17, 22 August 2019 by Snake (talk | contribs) (→‎Benchmarks)
Jump to navigationJump to search

The Raspberry Pi 4 has been tested with ZM 1.32.3 and Buster. the RPI4 requires Buster, so Stretch isn't an option.

Buster has had some issues with ZM, but I think its API issues, or something we can ignore for now. I forget the details, check the forums. It may be because AMD64 has no ZMRepo builds for Buster (as of yet), but Raspbian has 1.32.3 so not an issue.

RPI4 can't boot from USB natively, yet. You can do a workaround, but its a bunch of steps. (https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=44177) I will wait until boot from usb is fixed, instead of dealing with above. But I would recommend an external SSD or HDD for all the video and picture storage.

Raspbian might have better performance than Ubuntu or Debian RPI images due to fixes tailored for the RPI. Some things are certainly more streamlined, such as the SD Card auto resizing upon dd'ing the Raspbian image. In Debian and Ubuntu resizing the SD card filesystem is a manual step.

H264 encode isn't available but passthrough is. JPEG is an option if you can't use passthrough.

When booting RPI4, i tried an hdmi cable to hdmi to hdmi micro adapter, but it didn't work - the monitor kept shutting off. However, i had a hdmi to hdmi micro cable and that worked.

Preparation

login pi/raspberry

change password

sudo su to root

change root pass

edit ssh settings

enable / start ssh

ZM Install

This guide will follow https://wiki.zoneminder.com/Debian_10_Buster_with_Zoneminder_1.32.3_the_Easy_Way?title=Debian_10_Buster_with_Zoneminder_1.32.3_the_Easy_Way&oldid=15622 but instead of deb multimedia use raspbians 1.32.3 image.

get rid of non-free in /apt/sources.list

sudo apt update

Install LAMP

sudo apt-get install apache2 mariadb-server
sudo mysql_secure_installation
sudo apt install php libapache2-mod-php php-mysql

Install and Configure Zoneminder

sudo apt install zoneminder vlc-plugin-base
sudo mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql

edit the following user / pass as necessary

sudo mysql -uroot -p -e "grant all on zm.* to 'zmuser'@localhost identified by 'zmpass';"
sudo mysqladmin -uroot -p reload 
sudo chmod 740 /etc/zm/zm.conf 
sudo chown root:www-data /etc/zm/zm.conf
sudo chown -R www-data:www-data /usr/share/zoneminder/
sudo chown -R www-data:www-data /var/cache/zoneminder/
sudo systemctl enable zoneminder.service
sudo adduser www-data video

Note that if zm fails to start, and you have changed the mysql user/password, be sure to edit /etc/zm/zm.conf with the new user/password

sudo systemctl start zoneminder.service
sudo systemctl status zoneminder.service
sudo a2enmod cgi
sudo a2enmod rewrite
sudo a2enconf zoneminder
sudo nano /etc/php/7.3/apache2/php.ini


Search for [Date] (Ctrl + w then type Date and press Enter) and make changes as follows for your time zone

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone 
date.timezone = America/New_York

Optional Tweaks

apt-get remove avahi-daemon #security risk
dpkg-reconfigure locales
  1. check locale
locale

Configure Wifi

if you need wifi do something like the following:

in /etc/network/interfaces put


allow-hotplug wlan0
iface wlan0 inet dhcp
   wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
   source-directory /etc/network/interfaces.d
   auto eth0
iface eth0 inet static
       address 192.168.1.100
       netmask 255.255.255.0


in /etc/wpa_supplicant/wpa_supplicant.conf put:

    ctrl_interface=/var/run/wpa_supplicant
network={
       ssid="SSIDgoeshere"
       psk="passwordgoeshere"
}

Note that this doesn't work on ubuntu because netplan is the new networking package... Instead, you have to uninstall netplan.io and install the ifupdown package. Note that this is subject to change due to devs endlessly reinventing the wheel. How else will programmers have a job if they don't break things that work? https://www.raspberrypi.org/forums/viewtopic.php?p=1499060


Default ZM RPI4 Install, sits at 190M RAM, Load averages 0.01, 0.21, 0.41 100M of swap


It's recommended you use an external HDD for the RPI to record videos from ZM. Otherwise you will exhaust the amount of writes available to the flash on the sd card. When boot from USB is possible, that will be recommended.

Conclusion

The RPI4 is currently the most powerful RPI available. There are 1GB, 2GB, and 4GB versions available. For ZM, I would recommend either the 2GB or the 4GB. The additional RAM does not make ZM much more powerful than the previous RPI3, but it helps. In the end, the CPU is the limiting factor, and as with all ARM boards, you find that it can't compete with X86-64. But for small setups, the RPI4 is useful, or as an adjunct to a large setup.

There has been some hype about this pi being the fastest ever, and how it's going to overtake desktops. Yes, this is a faster pi than the RPI3, but it's not significantly faster. It's a step ahead - that's it. Disregard the hyperbole about exaggerated performance gains. It's what you would expect from the successor to the RPI3. The additional RAM helps, but cameras will still drop out. The RAM doesn't stop that.

Benchmarks

1280x720 4FPS Record - 2.1 Load - stable (moderate motion)
1280x720 6FPS Record - 3.5 Load - unstable (moderate motion)

When testing the RPI4, if you are having trouble getting a stream to be stable, do one or more of the following:

  • Lower FPS
  • Lower Resolution
  • Lower Zone size or Disable Analysis completely (ergo use Record instead of Modect or Mocord)

Many cameras, such as Hikvision offer 2 (or even 3) streams that can be adjusted to give you a range of options. H264 Passthrough is recommended for the best performance, and long term storage ability. However, short term storage of MJPEG will also be efficient (at the cost of losing compression on saved video/images), if the stream is MJPEG. Different cameras will perform differently on the Pi.