Difference between revisions of "Raspberry Pi 4 - Raspbian"

From ZoneMinder Wiki
Jump to navigationJump to search
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{AllSBCAreHereLink}}
The Raspberry Pi 4 has been tested with ZM 1.32.3 and Buster. the RPI4 requires Buster, so Stretch isn't an option.
The Raspberry Pi 4 has been tested with ZM 1.32.3 and Buster. the RPI4 requires Buster, so Stretch isn't an option.
This guide will also likely work on other RPIs that use Buster.


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.
I would recommend to set the RPI4 to boot from external USB HDD or at least an external for all the video and picture storage of ZM. Also disable logging on ZM after you get it working. (Options - Logs) if you are using an SSD or SD card.


RPI4 can't boot from USB natively, yet. You can do a workaround, but its a bunch of steps.
A guide to putting the rootfs on an external usb drive, is here: http://web.archive.org/web/https://gist.github.com/lucabelluccini/9a11c48dcf1d627bbcbd8213f6de3eae
(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.
Raspbian might have better performance than Ubuntu or Debian RPI images due to fixes tailored for the RPI. Some things are 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.
If you need H264 Encoding, 1.33 / 1.34 will have that as an option. 1.32.3 has support for H264 passthrough and JPEG recording only. 1.33/1.34 will be available at [[ZMRepo]] at some point.
 
ZM 1.32 on ARM has a bug where by default it's set to use the H264 encoding. Change that to H264 passthrough. Passthrough has less CPU usage than H264 encoding or the JPEG saving. Alternatively, you can try the JPEG saving, but it will be less efficient.
 
See [[Single_Board_Computers#GPU_Memory]] for a possible performance boost.


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.  
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.  
See also:
* [[Single_Board_Computers]]
* [[Debian]] - Most up to date installation docs for 1.34 can be found here.


==Preparation==
==Preparation==
Line 30: Line 39:
This guide will follow
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
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.
but instead of deb multimedia use raspbians 1.32.3 image. If you want to use more up to date editions of Zoneminder, see [[Debian]]. 1.32 and 1.34 is a stable release (1.33 and 1.35 is development).  


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


===Install LAMP===
===Install LAMP===
Line 48: Line 58:
  sudo chmod 740 /etc/zm/zm.conf  
  sudo chmod 740 /etc/zm/zm.conf  
  sudo chown root:www-data /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 chown -R www-data:www-data /var/cache/zoneminder/
  sudo systemctl enable zoneminder.service
  sudo systemctl enable zoneminder.service
Line 71: Line 80:
===Optional Tweaks===
===Optional Tweaks===


  apt-get remove avahi-daemon #security risk
  apt-get remove avahi-daemon #security risk, not needed for basic setups
apt-get remove bluez alsa-utils (not needed)
  dpkg-reconfigure locales
  dpkg-reconfigure locales
#check locale
#check locale
  locale
  locale
The following was mentioned in the forums as helping (unverified)
Increase GPU memory via
/boot/config.txt
gpu_mem=512


===Configure Wifi===
===Configure Wifi===
Line 80: Line 94:


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




in /etc/wpa_supplicant/wpa_supplicant.conf put:
in /etc/wpa_supplicant/wpa_supplicant.conf put:


    ctrl_interface=/var/run/wpa_supplicant
ctrl_interface=/var/run/wpa_supplicant GROUP=netdev
update_config=1
  network={
  network={
         ssid="SSIDgoeshere"
         ssid="SSIDgoeshere"
         psk="passwordgoeshere"
         psk="passwordgoeshere"
  }
  }
That's all that is needed for a basic wifi setup (with ifupdown package). If you have an unusual wifi setup then you may need additional parameters. e.g. if you have a hidden SSID, you have to add scan_ssid=1 to the network section.


Note that this doesn't work on ubuntu because netplan is the new networking package...
Note that this doesn't work on ubuntu because netplan is the new networking package...
Line 119: Line 136:
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.
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.
There has been some hype about this pi being the fastest ever, and how it's going to be usable as a desktop. Yes, this is a faster pi than the RPI3, but it's not significantly faster. It's a step ahead - that's it. Ignore 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. The pi was always usable as a desktop computer, but only for low CPU tasks.


===Benchmarks===
===Benchmarks===
Line 125: Line 142:
  1280x720 6FPS Record - 3.5 Load - unstable (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 of the following:
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 FPS
* Lower Resolution
* Lower Resolution
* Lower Zone size or Disable Analysis completely (ergo use Record instead of Modect or Mocord)
* 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.
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.

Latest revision as of 12:56, 12 May 2020

Note: For a full listing of RPI/ARM based install docs see Single Board Computers

The Raspberry Pi 4 has been tested with ZM 1.32.3 and Buster. the RPI4 requires Buster, so Stretch isn't an option. This guide will also likely work on other RPIs that use Buster.

I would recommend to set the RPI4 to boot from external USB HDD or at least an external for all the video and picture storage of ZM. Also disable logging on ZM after you get it working. (Options - Logs) if you are using an SSD or SD card.

A guide to putting the rootfs on an external usb drive, is here: http://web.archive.org/web/https://gist.github.com/lucabelluccini/9a11c48dcf1d627bbcbd8213f6de3eae

Raspbian might have better performance than Ubuntu or Debian RPI images due to fixes tailored for the RPI. Some things are 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.

If you need H264 Encoding, 1.33 / 1.34 will have that as an option. 1.32.3 has support for H264 passthrough and JPEG recording only. 1.33/1.34 will be available at ZMRepo at some point.

ZM 1.32 on ARM has a bug where by default it's set to use the H264 encoding. Change that to H264 passthrough. Passthrough has less CPU usage than H264 encoding or the JPEG saving. Alternatively, you can try the JPEG saving, but it will be less efficient.

See Single_Board_Computers#GPU_Memory for a possible performance boost.

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.

See also:

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. If you want to use more up to date editions of Zoneminder, see Debian. 1.32 and 1.34 is a stable release (1.33 and 1.35 is development).

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 /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, not needed for basic setups
apt-get remove bluez alsa-utils (not needed)
dpkg-reconfigure locales
  1. check locale
locale

The following was mentioned in the forums as helping (unverified)

Increase GPU memory via
/boot/config.txt 
gpu_mem=512

Configure Wifi

if you need wifi do something like the following:

in /etc/network/interfaces put

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
   wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
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 GROUP=netdev
update_config=1
network={
       ssid="SSIDgoeshere"
       psk="passwordgoeshere"
}

That's all that is needed for a basic wifi setup (with ifupdown package). If you have an unusual wifi setup then you may need additional parameters. e.g. if you have a hidden SSID, you have to add scan_ssid=1 to the network section.

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 be usable as a desktop. Yes, this is a faster pi than the RPI3, but it's not significantly faster. It's a step ahead - that's it. Ignore 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. The pi was always usable as a desktop computer, but only for low CPU tasks.

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.