Skip to content

Commit

Permalink
first commit v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenVD committed Aug 12, 2018
1 parent a59ff6a commit 4ad9c0a
Show file tree
Hide file tree
Showing 25 changed files with 1,090 additions and 432 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ target/
# Pycharm
.idea

# vscode
.vscode

*.log
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,3 @@ proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

59 changes: 35 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,84 @@
# rpisurv - Raspberry pi surveillance an RPI IP Camera Monitor
# rpisurv 2.0 - Raspberry pi surveillance an RPI IP Camera Monitor
Follow us on facebook https://www.facebook.com/rpisurv

If you like this software please consider donating:
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QPJU9K2KZ8D94" target="_blank" rel="nofollow"><img src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" alt="" /></a>

## Release notes

See [RELEASE_NOTES](https://github.com/SvenVD/rpisurv/blob/master/RELEASE_NOTES.md)

Note: Debug logging will be enabled by default during beta phase.

## Goal
Rpisurv is designed to be simple to use. The goal is to connect your raspberry pi to a monitor, tell rpisurv which rtsp streams it should display and tell it the max number of "columns" of streams you want. It will then autocalculate the rest, like how many rows are needed etc ...
Rpisurv is designed to be simple to use (no need to fiddle with coordinates or detailed layout configs) and to be able to run unattended for long periods of time. Therefore watchdogs and autohealing logic have been implemented.
Versions 2.0 adds functionality to define multiple screens which can be cycled between.

## Description
You can think of rpisurv as a wrapper for omxplayer with following features. Rpisurv uses omxplayer to fully make use of the GPU of the raspberry pi.
You can think of rpisurv as a wrapper for omxplayer with following features (Rpisurv uses omxplayer to fully make use of the GPU of the raspberry pi).

- Rpisurv implements a watchdog for every stream displayed, if the process gets killed somehow. It will try to restart the stream/process. This gives you a very robust surveillance screen.
- Autocalculcate coordinates for every stream displayed. The last stream defined will be stretched to make use of the complete screen but only if some pixels are unused (if autostretch option is True).
- RTSP stream up/down detection and autorearrange of the screen layout. So for example if you stop a camera (or just stop the rtsp server on the camera), rpisurv will detects this and will recalculate/redraw the screen with the still available cameras. The same is true if a previous unconnectable rtsp stream becomes connectable. All without any user interaction.
- Stream up/down detection and autorearrange of the screen layout (if disable_probing_for_all_streams is False). So for example if you stop a camera (or just stop the server on the camera), rpisurv will detects this and will recalculate/redraw the screen with the still available cameras. The same is true if a previous unconnectable rtsp stream becomes connectable. All without any user interaction.
- All this behaviour is available per screen, but as of 2.0 you can configure multiple screens and cycle between them in an automated way.

## How to get started

In short: The idea is to connect your raspberry pi to a monitor and tell rpisurv which stream(s) and screen(s) it should display or cycle between. Rpisurv will autocalculate all the rest.
- Get a monitor or a TV
- Get a raspberry pi dedicated for rpisurv, and install raspbian on it. Make sure your monitor is operating at the correct resolution
- If you are going to have multiple streams, add gpu_mem=512 to your /boot/config.txt
- git clone this repository: `git clone https://github.com/SvenVD/rpisurv`
- move into folder `cd rpisurv`
- run `sudo ./install.sh`
- Get the correct rtsp stream url for your ip camera(s), there are some examples in /etc/rpisurv
- configure your rtsp streams in /etc/rpisurv ( do NOT use tabs in this file, only use spaces! ).
- configure your max number of columns in /etc/rpisurv
- Get the correct stream url for your ip camera(s), there are some examples in /etc/rpisurv
- configure your screen(s) and stream(s) in /etc/rpisurv.
- OPTIONAL: configure optional options per screen or per camera stream in /etc/rpisurv, the [example config file](https://github.com/SvenVD/rpisurv/blob/master/surveillance/conf/surveillance.yml) file explains them all
- reboot

## How to update
- save your config:
`cp -v /usr/local/bin/rpisurv/conf/surveillance.yml /usr/local/bin/rpisurv/conf/surveillance.yml.back_update`
## How to update <a name="how-to-update"></a>
- `cd rpisurv; git pull`
- run `sudo ./install.sh`
- restore your config:
`cp -v /usr/local/bin/rpisurv/conf/surveillance.yml.back_update /usr/local/bin/rpisurv/conf/surveillance.yml`
- `sudo systemctl restart rpisurv`
- run `sudo ./install.sh` (The installer will ask if you want to preserve your current config file)
- `systemctl restart rpisurv`

## Placeholder images
After installation you may change the placeholder images to something you like.
- /usr/local/bin/rpisurv/images/connecting.png is shown when a camera stream is starting up
- /usr/local/bin/rpisurv/images/placeholder.png is shown on empty squares
- /usr/local/bin/rpisurv/images/noconnectable.png is shown full screen when no connectable streams are detected
- `sudo systemctl restart rpisurv`
- /usr/local/bin/rpisurv/images/noconnectable.png is shown full screen when no connectable streams are detected for the current active screen in case multiple are cycled between
- `systemctl restart rpisurv`

## Rpisurv in operation

If you used the install.sh script, you can configure your streams in /etc/rpisurv. Do not forget to reboot afterwards.

If you are connected via keyboard, you can force the next screen rpisurv by pressing and holding n or space for some seconds in case multiple screens were defined (this takes longer depending on amount of unconnectable streams and they thus need to wait for timeout, keep holding until screen changes. Note, you can change probe_timeout per camera stream if needed).

Keys F1 to F12, will force the equal numbered screen to be shown onscreen (this takes longer depending on amount of unconnectable streams and they thus need to wait for timeout, keep holding until screen changes. Note, you can change probe_timeout per camera stream if needed).

Disable rotation (as in pause rotation, as in fix the current displayed screen) dynamically during runtime. By pressing "p" to pause or "r" to resume/rotate. This overrides the disable_autorotation option if this has been set in the config file.


## Troubleshooting

- I advise you to test your rtsp urls in vlc or omxplayer (command line) first. It should work in these applications before attempting to use them in rpisurv
- I advise you to test your urls in vlc or omxplayer (command line) first. It should work in these applications before attempting to use them in rpisurv

- If you used the install.sh script, logs are created at /usr/local/bin/rpisurv/logs/. You can use them for troubleshooting.
- If you used the install.sh script, logs are created at /usr/local/bin/rpisurv/logs/. You can use them for troubleshooting. Enable DEBUG logging for very detailed output of what is going on. see [logging_config](https://github.com/SvenVD/rpisurv/blob/master/surveillance/conf/logging.yml)

- If you are connected via keyboard, you can stop rpisurv by pressing q for about 25 seconds.
- If you are connected via keyboard, you can stop rpisurv by pressing and holding q (this can take some seconds) .

- To manage the screen without rebooting use systemctl
- `sudo systemctl stop rpisurv` to stop the screen
- `sudo systemctl start rpisurv` to start the screen
- `sudo systemctl status rpisurv` to see last log and status of service
- DEPRECATED: To start the screen without rebooting on non systemd enabled raspbian, run `cd /usr/local/bin/rpisurv; sudo python surveillance.py`

- If you want to stream rtsp over tcp please add `rtsp_over_tcp: true` to the stream in /etc/rpisurv.
See https://github.com/SvenVD/rpisurv/blob/master/surveillance/conf/surveillance.yml for an example.
See [example config file](https://github.com/SvenVD/rpisurv/blob/master/surveillance/conf/surveillance.yml) for an example.
If you have a "smearing" effect this option may resolve it.
Note that you need a version of omxplayer which is released afer 14 March 2016 (https://github.com/popcornmix/omxplayer/pull/433) to do this.
Note that you need a version of omxplayer older then 14 March 2016 (https://github.com/popcornmix/omxplayer/pull/433) to do this.

- On a raspberry pi 3 it seems the default overscan settings are not good. If full screen is not used, if you have an unused bar in the bottom -> try to set `disable_overscan=1` in /boot/config.txt


## Feature requests

Feature requests are tracked on https://feathub.com/SvenVD/rpisurv. If you would like to have a feature implemented on rpisurv, please check that this is not already been requested on feathub. If it is then add your vote to it, if it is not then request it as a new feature. The votes give us an indication on how feature requests compare to each other regarding popularity.
Feature requests are tracked on https://feathub.com/SvenVD/rpisurv. If you would like to have a feature implemented on rpisurv, please check that this is not already been requested on feathub. If it is then add your vote to it, if it is not then request it as a new feature. The votes give us an indication on how feature requests compare to each other regarding popularity.
25 changes: 25 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# rpisurv 2.0.beta1 release notes
## Upgrade notes from 1.0
The config file is still a yaml file but the keys have been changed to support the configuration of multiple screen in a rotation
You must manually convert your 1.0 config file to the new 2.0 config file format. However the format is still as clear to use, but it is still a yaml file. So as always watch the indentations and do not use tabs, see [example config file](https://github.com/SvenVD/rpisurv/blob/master/surveillance/conf/surveillance.yml)
The normal update [procedure](https://github.com/SvenVD/rpisurv/blob/master/README.md#how-to-update) can be followed for upgrading.

## Features and changes since 1.0
- Implemented "Automatic cycle through list of cameras/screens" [link](https://feathub.com/SvenVD/rpisurv/+4).
- Pressing keys F1 to F12 on an attached keyboard, will force the equal numbered screen to be shown onscreen (this takes longer depending on amount of unconnectable streams and they thus need to wait for timeout, keep holding until screen changes. Note, you can change probe_timeout per camera stream if needed). Example use case: you can define one '4x4' screen and 4 1x1 screens with the same camera streams. That way you can select one camera stream out of the 4x4 by pressing F2-F5 and go back to 4x4 by pressing F1 [link](https://feathub.com/SvenVD/rpisurv/+3).
- Disable rotation (as in pause rotation, as in fix the current displayed screen) dynamically during runtime. Press "p" to pause and "r" to resume/rotate. This overrides the disable_autorotation option if this has been set in the config file.
- There is virtually no limit(hardware or software) for the amount of screens that can be defined.
- Implemented "Add mjpeg camera support" [link](https://feathub.com/SvenVD/rpisurv/+5) but not limited to mjpeg support, all omxplayer supported http/https streams can be configured.
- Possibility to force next screen in a carousel/slideshow by pressing "n" or "space" on an attached keyboard.
- Enabling the user to configure the duration of each screen in the carousel/slideshow by overriding the default with the option duration, see [example config file](https://github.com/SvenVD/rpisurv/blob/master/surveillance/conf/surveillance.yml).
- Enabling the user to specify a probe_timeout per camera stream. This for slow connecting streams to not be regarded as unconnectable by rpisurv, see [example config file](https://github.com/SvenVD/rpisurv/blob/master/surveillance/conf/surveillance.yml).
- keep_first_screen_layout option in v1.0 has been replaced by disable_probing_for_all_streams in v2.0 and has become a per screen configuration, which effect is roughly the same. (Not recommended to enable this though).
- All existing functionality from v1.0 is still available. If you only define one screen you essentially get the rpisurv v1.0 behaviour.
- rtps_urls config option which was already deprecated in v1.0 is now completely removed.
- autostretch and nr_of_columns options are now per-screen configuration options.
- Installer has been updated to request the user to preserve his current configuration file.





20 changes: 18 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ get_init_sys
BASEPATH="$(cd $(dirname "${BASH_SOURCE[0]}");pwd)"

#Install needed packages
sudo apt-get install python-pygame python-yaml python libraspberrypi-bin rsync -y
sudo apt-get install coreutils python-pygame python-yaml python-dbus python libraspberrypi-bin -y

#Only install omxplayer if it isn't already installed (from source or package)
if [ ! -e /usr/bin/omxplayer ];then
Expand Down Expand Up @@ -55,14 +55,30 @@ fi
SOURCEDIR="$BASEPATH/surveillance"
MAINSOURCE="surveillance.py"
CONFFILE="conf/surveillance.yml"
BACKUPCONFFILE=/tmp/surveillance.yml.$(date +%Y%m%d_%s)



DESTPATH="/usr/local/bin/rpisurv"
sudo mkdir -p "$DESTPATH"

sudo rsync -av "$SOURCEDIR/" "$DESTPATH/"
if [ -f "$DESTPATH/$CONFFILE" ]; then sudo cp -v "$DESTPATH/$CONFFILE" "${BACKUPCONFFILE}";fi
echo
echo "Existing config file will be backed up to "${BACKUPCONFFILE}""


echo
echo "Do you want to overwrite you current config file with the example config file?"
echo "Newer major versions of rpisurv are not backwards compatible with old format of config file"
echo "Type yes/no"
read ANSWER

sudo rsync -av "$SOURCEDIR/" "$DESTPATH/"

if [ x"$ANSWER" == x"no" ]; then
#Putting back old config file
if [ -f "${BACKUPCONFFILE}" ]; then sudo cp -v "${BACKUPCONFFILE}" "$DESTPATH/$CONFFILE" ; fi
fi

STARTUPCMD="cd $DESTPATH; python "$MAINSOURCE" &"

Expand Down
4 changes: 3 additions & 1 deletion rpisurv
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#!/bin/bash
cd /usr/local/bin/rpisurv; python surveillance.py
#Removing leftover dbus connections first
/bin/rm -fv /tmp/omxplayerdbus*
cd /usr/local/bin/rpisurv; python surveillance.py
2 changes: 2 additions & 0 deletions rpisurv.service
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
[Unit]
Description=Rpisurv Raspberry Pi Surveillance
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/rpisurv
ExecStop="/bin/rm -fv /tmp/omxplayerdbus*"
KillMode=control-group
Restart=on-failure

Expand Down
Empty file added surveillance/__init__.py
Empty file.
Loading

0 comments on commit 4ad9c0a

Please sign in to comment.