Dedicated SBC Camera Monitor

From ZoneMinder Wiki
Revision as of 06:42, 3 November 2023 by Burger (talk | contribs) (→‎OS)
Jump to navigationJump to search

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.

Update: 08/2018 Tested with Rpi3 and Debian Stretch migrated to Devuan Ascii here Dedicated_RPI_Camera_Monitor

Another companion to this guide is the Desktop_SBC_Camera_Monitor

11/2018: See also Zoneminder Blogspot - ODroid XU4 Zoneminder Client guide.

Setup

Installation

Requirements

  • >4GB HDD / SD
  • SBC / Desktop / Laptop
  • 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.

Auto Start Computer

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

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

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 &
/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

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.

Full Screen Video Feed

Two options come to mind:

  • Point browser to a local html page with the link to the monitor embedded in an img tag

OR

  • have a local web server run and point surf to a hosted html page.

First Is easiest. Make an html file. Be sure to include http prefix.

<html>
<img width="###px" height=###px" src="http://serverip/zm/cgi-bin/nph-zms?mode=jpeg&monitor=####&scale=100&maxfps=5&user=username&pass=password" />
</html>

Call it on .xinitrc before dwm

surf file:///home/username/file.html &

Customize the width and height of the img tag to fit your monitor. In my case I put st in the .xinitrc of my beagle instead of surf, restarted, and from the terminal ran xrandr to see what display it was using. I had 1440x900 but the width and height I could get out of surf without borders causing trouble was 1415 and 875. Multiple img tags can be embedded into an html file however you like. See also Example Camera View HTML

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.

Todo

  • Make a guide similar to the above, but using stali, sabotage, or a similar static binary distro (would be faster / leaner). Alpine is the mainstream option in this category.

Notes / Errata

  • dd or clonezilla the disc to an img to deploy in multiple places .
  • When troubleshooting any dropouts from watching the video feed, make sure to downscale the video, per External Live Stream for clients.

Troubleshooting

Installing and updating is slow!

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.

How do I disable keypresses for kiosk mode?

I don't have the need, but it's possible to do further lockdown. Look online.


See Also