wiki:RaspberryPiSurveillanceMonitor

I have 2 FOSCAM HD IP camera and 1 UBNT airVision (old model) IP camera which are used for surveillance monitoring. Storage of images is done on the camera's itself, so I only needed something to view the live feeds of the camera's combined an a single screen. I had an old HDMI screen laying around and the Raspberry Pi 3 is yet the perfect (inexpesive fit) for this purpose.

Getting started

Install the standard debian Raspberry Pi and make sure to select console mode. We do need any GUI, since we will be using omxplayer to display the camera feeds. Also find out your RTSP streaming URLs.

Display camera images

I use the daemontools framework, since it provides me with logging, monitoring, restarting out-of-the-box. I also like the way his way of thinking, to avoid reinventing the wheel everytime you need to write an deamon.

/etc/motd:

WWW: http://rickvanderzwet.nl - webcampi @ rustdam

/etc/service/camera1 	=	Hooiberg (via 'Rustdam Stal') - Main View
/etc/service/camera2	=	Receptie (via wired and proxied on rustdam2.gw) - Left bottom
/etc/service/camera3	=	Stal	(wireless connected to rustdam.wleiden.net - rdr at rustdam2.gw) 

/etc/service/camera1/run:

#!/bin/sh
exec 2>&1
exec omxplayer --threshold 0 --win 0,0,1280,720 --live 'rtsp://USER:PASSWORD@IP:PORT/videoMain'

/etc/service/camera2/run:

#!/bin/sh
exec 2>&1
exec omxplayer --threshold 0 --win 739,720,1280,1024 --layer 10 --live 'rtsp://USER:PASSWORD@IP:PORT/videoMain'

/etc/service/camera3/run:

#!/bin/sh
exec 2>&1
exec omxplayer --threshold 0 --win 0,720,540,1024 --layer 10 --live 'rtsp://USER:PASSWORD@IP:PORT/videoMain'

Monitoring of camera feeds

/root/kill_stuck_omxplayer.sh:

#!/bin/sh
#
# Quick to deal with omxplayers which are in deadloop,
# detection based on low-CPU usage
#
for PID in `pgrep omxplayer.bin`; do
  PCPU=`ps -p $PID -o pcpu=`
  if echo $PCPU 2.0 | awk '{exit $1<$2?0:1}'; then
    echo "Lets kill pid $PID"
    kill -KILL $PID
  fi
done

/etc/crontab:

*  *    * * *   root    /root/kill_stuck_omxplayer.sh | logger
Last modified 5 months ago Last modified on Dec 1, 2016, 11:24:12 AM