Difference between revisions of "Dedicated SBC Camera Monitor"

From ZoneMinder Wiki
Jump to navigationJump to search
 
(125 intermediate revisions by 2 users not shown)
Line 1: Line 1:
A guide for setting up a dedicated SBC (here beaglebone) that will monitor the video feed from a camera that you choose. I'll also include some steps on getting a custom kernel for I2C. The WM will be DWM, terminal ST, and browser will be Surf. It will be a minimal installation with no DE, no extra programs. You will save RAM here, over an installation of LXDE, the default for the Beaglebone Black.
This is a guide for setting up a dedicated computer (core 2 duo or newer) or SBC (RPI recommended) to view all streams at once. I run this with about 28 streams with live montage of some reasonable slow but usable FPS on a mid-late 2000's used desktop. RPI's would probably only be able to run less streams, maybe 10-15.


I will also include some settings that turn this into a 'kiosk mode' video monitor, so it cannot be changed.


This page is a WIP. It was tested on Debian 8/9. This guide has some other tips in [[Dedicated_RPI_Camera_Monitor]] and [[Desktop_SBC_Camera_Monitor]]. These pages will be incorporated into one page as time permits. There are other ways to do this. You can also have ZMNinja on a dedicated client per http://zoneminder.blogspot.com/p/odroid.html
== Setup ==
== Setup ==
=== Installation ===


Requirements:
'''Requirements'''
* >=4GB SD Card
* >8GB HDD / SD
* SBC (although this works on a desktop)
* SBC (RPI4 or equivalent) / old pc (core 2 duo or newer)
* Internet connection
* Internet connection
* Computer monitor
* Computer monitor
* HDMI cable for BBB


Install beaglebone black using elinux.com's [http://elinux.org/BeagleBoardDebian BeagleBoardDebian] page.
This guide used to cover install steps for a BBB, but that will be kept in the history. This guide will now just cover general desktop setup steps.


Use the direct image (under Demo, below NetInstall). Not the netinstall, which is slower, unless you know what you are doing.
=== OS ===
Install debian without X/Wayland. Install only SSH and the file system utilities from the ISO wizard.


After you boot from SD card, migrate to devuan using this guide:
Install dwm from scratch or from the repos (scratch is easier for editing the config file).
apt-get install firefox-esr


Next complete the following commands
=== Auto Start Computer ===


<pre> su root</pre>
The first thing we want to do, is get it so the computer will start without user interaction.
<pre> apt-get install xorg libx11-dev libxft-dev libxinerama-dev gcc make htop sudo tcpdump</pre>
 
Complete these for Surf
Edit .xinitrc, /etc/rc.local, /etc/inittab, and .bash_profile to auto startx without requiring a login, load the browser (firefox, chromium, or surf) with the path of the zm server monitor feed, and disable the screensaver.
<pre> apt-get install libwebkitgtk-dev libgtk2.0-dev linux-headers-$(uname -r)</pre>
 
Then download our three stars of the night.
 
<pre> git clone http://git.suckless.org/dwm && git clone git://git.suckless.org/st && git clone git://git.suckless.org/surf</pre>
Added to /etc/inittab (comment out existing, and add this below. Replace username with your new user):
Edit the config for dwm
1:2345:respawn:/bin/login -f USERNAME tty1 </dev/tty1 >/dev/tty1 2>&1
<pre> nano dwm/config.def.h</pre>
 
* Disable the bar
 
* Remove all workspaces except for 1 (*tags)
Copy /etc/profile to user that will be auto logging in:
* (leave #1 only)
cp /etc/profile /home/USERNAME/.bash_profile
* Set Mod4Mask as modkey
 
* Set MODKEY|Shiftmask to 0 and XK_c to XK_F12 for killclient (personal preference)
 
*Later disable spawm of dmenucmd and termcmd, but for now leave enabled.
Appended to /home/USERNAME/.bash_profile :
exec startx
 
==== Browsers ====
When startx loads, it will pull settings from ~/.xinitrc for USERNAME so edit that (note that .xinitrc requires '''&''' after all commands that are not the final wm).
 
#!/bin/bash
/usr/local/bin/surf "localhost/zm/cgi-bin/nph-zms??mode=jpeg&monitor=1&scale=100&maxfps=5&buffer=1000&user=user&pass=pass" &
exec dwm
or firefox might look something like:
#!/bin/bash
/usr/bin/firefox &
exec dwm
or the path for chromium might be:
#!/bin/bash
chromium-browser --home-page http://127.0.0.1/resource --no-sandbox --window-size=1920,1280 --start-fullscreen --test-type
exec dwm
Note that only firefox can view more than 6 streams at once, and requires a switch in about:config to do this (see tips section).
 
==== Users & Screensaver ====
Add an additional user beside the one used for the auto login, otherwise ssh will fail.  
ssh will try to startx when it loads, and it won't be able to. Add USERNAME2 permissions to sudoers.
# adduser USERNAME2
nano /etc/sudoers
 
 
Disable screensaver for the first USERNAME per [https://wiki.archlinux.org/index.php/Display_Power_Management_Signaling Arch Wiki: Display Power Management Signaling]
 
nano /home/USERNAME/.xinitrc
export DISPLAY=:0 &
xset s off &
xset -dpms &
 
These go before the other commands in .xinitrc, as they have the & symbol.
The total .xinitrc will be something like:
#!/bin/bash
export DISPLAY=:0 &
xset s off &
xset -dpms &
<browser command here>
exec dwm
 
Note: When troubleshooting xset. You must be the same user that is running X (ssh in as different user, then su to user). And, you must export DISPLAY to :0 or similar. Finally xset q should query the current settings.
 
=== Fine Tuning ===
 
At this point, you should be able to boot the SBC or desktop and receive a video feed without user interaction. All the users have to do is press the power button.
 
==== Choosing the proper page to view on the browser ====
 
See [[External Live Stream]]. I currently use the API version, where you host the page on the ZM server. It's easier to manage multiple machines pointing to one server than to manage each machines self hosted page.
 
==== Refresh Screen Periodically ====
 
You will want to have the web browser refresh every few minutes. Otherwise, if the feed drops out, it will not return unless you reboot. The way I accomplished this was:
 
Install xdotool
# apt-get install xdotool
 
 
Edit surf config.h and add the following to the keybindings section, then make and make install.
{ 0, GDK_F5,  reload, { .b = FALSE } },
 
 
Add to /etc/crontab
DISPLAY=:0
*/5 * * * * username /usr/bin/xdotool key F5
 
 
To make sure this works, with the browser watching a camera stream, restart apache2 on the ZM server, and the browser feed will freeze. A successful F5 from xdotool will refresh the screen, as long as surf has a keybinding for it.
 
==== Accessing headless X via VNC ====
 
In the case that you have a headless device (no monitor attached) yet X is running, here's some tips for accessing the desktop via VNC.


<pre>
<pre>
cd dwm
sudo apt-get install xserver-xorg-legacy
make
add:
make install
allowed-users:anybody
cd ../st
in /etc/X11/Xwrapper.config
nano config.def.h
apt-get install x11vnc
</pre>
</pre>
* Set termname[] to xterm (resolves some issues with programs that don't understand default termname).
Final command may be something like
ssh -L 5900:localhost:5900 user@pineboard  x11vnc -safer  -localhost -nopw -once -auth /tmp/serverauth*   -display :0
 
If you are doing headless on vnc, get rid of startx on bash profile
and just run it manually.
 
Test x11vnc with
x11vnc -display :0
But none of the other flags to start. When in doubt, break the commands down to make troubleshooting easier.
 
== Tips ==
 
* dd or clonezilla the disc to an img to deploy in multiple places .
 
* When troubleshooting any streams that flicker, try to downscale the video, per [[External Live Stream]] for clients. I.e. include the stream=50 or some percentage lower than 100 in the ZM path.
 
* On an SBC a counterfeit SD card could be the cause. A counterfeit or non name brand SD may take one day, what takes 2 hours to do with a name brand card.
 
* It's possible to lock down the keyboard. I don't have the need, but you can make a reasonably secure kiosk. Look online.
 
* Firefox starts in workspace 9, so you might have to change over to it in dwm upon boot. You can remove all workspaces except for #1, and then ff will boot by default
 
* For viewing more than 6 monitors, you may need to use firefox. See [https://wiki.zoneminder.com/Dummies_Guide#Notes Dummies Guide - Notes]
 
* To start firefox in full screen mode: The best add-on for this I've found is [https://addons.mozilla.org/en-us/firefox/addon/mfull/ mFull]. It can be configured to load full screen, and to remove or autohide the toolbars and navigation bar. There is also RKiosk but this disables all keys and is not needed in my scenario. I've seen some strange behavior with this plugin. On some machines it works and on other machines it will not work. Note that mFull was used in Firefox 52 or earlier.
 
* To shutdown, use crontab.
<pre>
<pre>
make
# nano /etc/crontab
make install
00 18 * * * root /sbin/poweroff
cd ../surf
nano config.def.h
</pre>
</pre>
* Set runinfullscreen to TRUE
The problem is you need full path to poweroff or shutdown -h now. If you are on a separate lan, you may need to use ntp and query some local ntp server, if RTC is off.
<pre>
 
make
== See Also ==
make install
 
</pre>
*[[Desktop SBC Camera Monitor]]
=== Intermediate Cleanup Time ===
 
<pre>apt-get remove nfs-common rpcbind wpasupplicant avahi-daemon ofono apache2</pre>
*[[Beaglebone Black - Devuan Jessie]]
Of course, leave wpasupplicant if you use wifi.
Net installer may want to install acpid.


Should be about 40MB RAM, and <5% CPU.
*[http://zoneminder.blogspot.com/p/odroid.html Zoneminder Blogspot - ODroid XU4 Zoneminder Client]
Remove Exim4 if you want as well.


=== Clock ===
*[https://wiki.alpinelinux.org/wiki/Raspberry_Pi_3_-_Browser_Client#Digital_Signage Alpine Linux Version] - The above guide was adapted for digital signage on an RPI4
<pre># apt-get install ntpdate</pre>
Set cron to run ntpdate periodically
<pre>*/5 * * * * ntpdate pool.ntp.org</pre>
This is leaner than running ntpd 24/7


== I2C Configuration ==
[[Category:Dummies_Guide]]

Latest revision as of 06:20, 3 November 2023

This is a guide for setting up a dedicated computer (core 2 duo or newer) or SBC (RPI recommended) to view all streams at once. I run this with about 28 streams with live montage of some reasonable slow but usable FPS on a mid-late 2000's used desktop. RPI's would probably only be able to run less streams, maybe 10-15.


This page is a WIP. It was tested on Debian 8/9. This guide has some other tips in Dedicated_RPI_Camera_Monitor and Desktop_SBC_Camera_Monitor. These pages will be incorporated into one page as time permits. There are other ways to do this. You can also have ZMNinja on a dedicated client per http://zoneminder.blogspot.com/p/odroid.html

Setup

Installation

Requirements

  • >8GB HDD / SD
  • SBC (RPI4 or equivalent) / old pc (core 2 duo or newer)
  • Internet connection
  • Computer monitor

This guide used to cover install steps for a BBB, but that will be kept in the history. This guide will now just cover general desktop setup steps.

OS

Install debian without X/Wayland. Install only SSH and the file system utilities from the ISO wizard.

Install dwm from scratch or from the repos (scratch is easier for editing the config file).

apt-get install firefox-esr

Auto Start Computer

The first thing we want to do, is get it so the computer will start without user interaction.

Edit .xinitrc, /etc/rc.local, /etc/inittab, and .bash_profile to auto startx without requiring a login, load the browser (firefox, chromium, or surf) with the path of the zm server monitor feed, and disable the screensaver.


Added to /etc/inittab (comment out existing, and add this below. Replace username with your new user):

1:2345:respawn:/bin/login -f USERNAME tty1 </dev/tty1 >/dev/tty1 2>&1


Copy /etc/profile to user that will be auto logging in:

cp /etc/profile /home/USERNAME/.bash_profile


Appended to /home/USERNAME/.bash_profile :

exec startx

Browsers

When startx loads, it will pull settings from ~/.xinitrc for USERNAME so edit that (note that .xinitrc requires & after all commands that are not the final wm).

#!/bin/bash
/usr/local/bin/surf "localhost/zm/cgi-bin/nph-zms??mode=jpeg&monitor=1&scale=100&maxfps=5&buffer=1000&user=user&pass=pass" &
exec dwm

or firefox might look something like:

#!/bin/bash
/usr/bin/firefox &
exec dwm

or the path for chromium might be:

#!/bin/bash
chromium-browser --home-page http://127.0.0.1/resource --no-sandbox --window-size=1920,1280 --start-fullscreen --test-type
exec dwm

Note that only firefox can view more than 6 streams at once, and requires a switch in about:config to do this (see tips section).

Users & Screensaver

Add an additional user beside the one used for the auto login, otherwise ssh will fail. ssh will try to startx when it loads, and it won't be able to. Add USERNAME2 permissions to sudoers.

# adduser USERNAME2
nano /etc/sudoers


Disable screensaver for the first USERNAME per Arch Wiki: Display Power Management Signaling

nano /home/USERNAME/.xinitrc
export DISPLAY=:0 &
xset s off &
xset -dpms &

These go before the other commands in .xinitrc, as they have the & symbol. The total .xinitrc will be something like:

#!/bin/bash
export DISPLAY=:0 &
xset s off &
xset -dpms &
<browser command here>
exec dwm

Note: When troubleshooting xset. You must be the same user that is running X (ssh in as different user, then su to user). And, you must export DISPLAY to :0 or similar. Finally xset q should query the current settings.

Fine Tuning

At this point, you should be able to boot the SBC or desktop and receive a video feed without user interaction. All the users have to do is press the power button.

Choosing the proper page to view on the browser

See External Live Stream. I currently use the API version, where you host the page on the ZM server. It's easier to manage multiple machines pointing to one server than to manage each machines self hosted page.

Refresh Screen Periodically

You will want to have the web browser refresh every few minutes. Otherwise, if the feed drops out, it will not return unless you reboot. The way I accomplished this was:

Install xdotool

# apt-get install xdotool


Edit surf config.h and add the following to the keybindings section, then make and make install.

{ 0, GDK_F5,  reload, { .b = FALSE } },


Add to /etc/crontab

DISPLAY=:0
*/5 * * * * username /usr/bin/xdotool key F5


To make sure this works, with the browser watching a camera stream, restart apache2 on the ZM server, and the browser feed will freeze. A successful F5 from xdotool will refresh the screen, as long as surf has a keybinding for it.

Accessing headless X via VNC

In the case that you have a headless device (no monitor attached) yet X is running, here's some tips for accessing the desktop via VNC.

sudo apt-get install xserver-xorg-legacy
add:
allowed-users:anybody 
in /etc/X11/Xwrapper.config
apt-get install x11vnc

Final command may be something like

ssh -L 5900:localhost:5900 user@pineboard  x11vnc -safer  -localhost -nopw -once -auth /tmp/serverauth*   -display :0 

If you are doing headless on vnc, get rid of startx on bash profile and just run it manually.

Test x11vnc with

x11vnc -display :0

But none of the other flags to start. When in doubt, break the commands down to make troubleshooting easier.

Tips

  • dd or clonezilla the disc to an img to deploy in multiple places .
  • When troubleshooting any streams that flicker, try to downscale the video, per External Live Stream for clients. I.e. include the stream=50 or some percentage lower than 100 in the ZM path.
  • On an SBC a counterfeit SD card could be the cause. A counterfeit or non name brand SD may take one day, what takes 2 hours to do with a name brand card.
  • It's possible to lock down the keyboard. I don't have the need, but you can make a reasonably secure kiosk. Look online.
  • Firefox starts in workspace 9, so you might have to change over to it in dwm upon boot. You can remove all workspaces except for #1, and then ff will boot by default
  • To start firefox in full screen mode: The best add-on for this I've found is mFull. It can be configured to load full screen, and to remove or autohide the toolbars and navigation bar. There is also RKiosk but this disables all keys and is not needed in my scenario. I've seen some strange behavior with this plugin. On some machines it works and on other machines it will not work. Note that mFull was used in Firefox 52 or earlier.
  • To shutdown, use crontab.
# nano /etc/crontab
00 18 * * * root /sbin/poweroff

The problem is you need full path to poweroff or shutdown -h now. If you are on a separate lan, you may need to use ntp and query some local ntp server, if RTC is off.

See Also