RaspberryPi as a NVR solution

Recently, one of my close relative wanted to install a security plan into his house using a CCTV solution (closed circuit television aka video surveillance). We got some quotations which were clearly out of budget for us (the lowest price was 1300€, including 4 cameras, a NVR box and the setup).

My challenge was to cut the price at least by 2, including the hardware, the software and the setup. The underlying benefit is also to explore and to learn.

Key Take aways

I like starting with the take aways first so you can read further the details if interested.

  • Don’t use a remote server as a NVR hardware solution. Use instead a local hardware, such as the raspberryPI one.
  • Thus, a raspberryPI with a light Operating system (Raspbian Stretch Lite) will be used as a NVR (Network Video Recording) hardware solution, as Raspberry has a H264 hardware encoding/decoding capabilities.
  • Shinobi is an Open Source CCTV solution that will install on that raspberry PI device and use it as a NVR software solution.
  • Purchase your cameras having 2 mandatory requirements : they should be IP compliant, and should be ONVIF standards compliant. Configuring your cameras within CCTV solution will be addressed in another blog post.

Software : Open Source Shinobi

Open Source doesn’t necessarely mean free, but it has the benefit to opening up the source code. And as a software engineer, I’d rather pay for a software that I can dig into and modify, rather than a closed one.

After investigation, there is an open source CCTV solution called shinobi that we’ll use. It is developed with nodeJs (javascript on server side). The project is quite active, and there are 2 versions : Community Edition, which is free and under GPLv3, and a Pro version, which has a monthly subscription and is under a specific EULA (end user licensing agreement). However, you can also use the Pro version for personal use also, which is my case.

Hardware : Cameras

There are a bunch of camera out there, with various capabilities and various prices ! Which one to purchase and install ?!

In this article, I won’t recommand you any particular camera device because it depends not only on ones budgets, but also on ones needs (night vision, detections, audio, lens quality…). But, there is definitely one point to take into account when purchasing yours : your camera should be an IP device, and it should be ONVIF compliant.

ONVIF is an open industry forum that provides and promotes standardized interfaces for effective interoperability of IP-based physical security products.

That means that whatever the manufacturer is, if your camera is ONVIF compliant, then it implements the open industry standards. This will give you the ability to interconnect many devices to each other, and most importantly for us, to use our Open Source Shinobi NVR to discover and communicate with our cameras.

I will make another post showing how to configure your cameras and plug them into Shinobi. But let’s first have shinobi running, which is the purpose of this artiche.

Hardware : Network Video Recorder

Remote server as a NVR hardware : bad solution

During my experiment, I first tried to install Shinobi on a remote server having an Atom N2800 1,86GHz, 4GB of RAM that I would use a NVR hardware. But to connect my cameras on that remote server, I had to configure my local router to port-forwad the real time stream from camera, but also its ONVIF protocol port. Also, there were a huge latency from streaming the camera to that remote NVR server (limited by my internet upload bandwidth).

So I decided to install an NVR hardware that would be on the same local network of the cameras. The benefits are multiple :

  • not opening the stream to outside (which could be a security breach).
  • having a close loop between the cameras and the NVR hardware on local network

Local server as a NVR hardware : better solution

Remote NVR server: very bad solution. So my choice went on using a raspberryPI. The price is really affordable for our use case (roughly 35€) and the hardware capabilities more than enough. The most important feature is its H264 hardware encoding/decoding capability.

I had one raspberryPI at home, which is the model 1B+ from 2014. It does the job, but if you are not equipped, I recommand to purchase the latest model to date (model 3 B+).

Installing Shinobi on Raspberry

Before installing any software on our raspberry, we need to install the Operating System. In our case, we’ll use a very light Raspbian version with no GUI

Install Raspbian on your PI

$ shasum -a 256 2018–11–13-raspbian-stretch-lite.zip

Log into your PI

  • Login into your raspberry. Default login is pi, password is raspberry.
  • First of all, change the password of the ‘pi’ user for security reason. To do so :
$ passwd
  • update packages on your PI if needed to have the latest versions of any of them
$ sudo apt-get update && sudo apt-get upgrade

Enable SSH on your raspberry

First of all, check on your raspberry if the SSH service is running

$ sudo service ssh status

(tip : you can check all services on your device by running the following command :

$ sudo service --status-all

If ssh is active, skip this step; otherwise, run the service

$ sudo service ssh start

# For future boots, you need to activate ssh on boot up
* solution 1

$ sudo update-rc.d ssh defaults
$ sudo update-rc.d ssh enable
  • solution 2
    or, You can also configure your raspberry by using the dedicated tool :
$ sudo raspi-config
>> Interface Settings
>> SSH
>> ENABLE

Access your raspberry by ssh

To access your device from your local network, you need to know its local IP address. However, this address is attributed by your router and might change over time.

  • So either set a static IP to your raspberryPI configuring your routeur (associating a static local IP to the MAC address of your raspberryPI).
  • Or, the prefered solution here : check the hostname of your raspberry by executing the command
$ hostname

In my case, the hostname of the device is raspberrypi. I can then easily ssh the pi without knowing its ip address, by the following command :

$ ssh pi@raspberrypi.local

Install Shinobi

Now that our OS is properly configured and that we can access to our device through ssh, let’s install Shinobi. The easiest way is to run the following command on your PI (as defined on the documentation) :

$ sudo su
$ sh <(curl -s https://gitlab.com/Shinobi-Systems/Shinobi-Installer/raw/master/shinobi-install.sh)

The installation will be interactive, as follow :

# install location
Install Location for Shinobi
*Note : Default install location is “/home”
Do you want to install a custom location for Shinobi?
(y)es or (N)o? Default : No
# shinobi version
Install Shinobi CE or Shinobi Pro?
— — — — — — — — — — — — — — — — — — — — — — -
*Note : Shinobi Pro is free for personal use.
*Learn more at http://shinobi.video/pro
— — — — — — — — — — — — — — — — — — — — — — -
©E or (P)ro? Default : Pro
# install branch (master in stable)
Install the Development branch?
(y)es or (N)o? Default : No
N
# OS selection
The installer will say that the OS is not detected. Select ubuntu instead.
Shinobi Installer
========
Select your OS
If your OS is not on the list please refer to the docs.
========
1. Ubuntu
2. CentOS
3. MacOS
4. FreeBSD
5. OpenSUSE
========
1
# DB : choose MariaDB as RDBMS and choose a root password
Shinobi — Do you want to Install MariaDB? Choose No if you already have it.
(y)es or (N)o
y
# install shinobi database
Shinobi — Database Installation
(y)es or (N)o
y
# configure Shinobi to start on boot
Shinobi — Start Shinobi and set to start on boot?
(y)es or (N)o
y

# installation size
The entire raspbian + shinobi (including all dependencies) only took less that 2GB of space.

$ df -hl
Filesystem Size Used Avail Use% Mounted on
/dev/root 7.3G 1.8G 5.2G 26% /

Now installation is complete !!!

Shinobi backoffice

The installation will tell you to open your browser with the following link :

|| Open http://192.168.0.10:8080/super in your web browser.
||===================================
|| Default Superuser : admin@shinobi.video
|| Default Password : admin

However, it is better to use the hostname to get rid of the uncertainty of the IP address of your device (that can change over reboot)

http://raspberrypi.local:8080/super

# change super user login/pwd
As soon as logged into http://raspberrypi.local:8080/super, change your login/pwd in the ‘Preferences’ tab for security reason.

# add a new user
Apart the super user, you need to add a user to shinobi (this user can have the same email).
This user would be able to log to the dashboard using directly this link on local network
http://raspberrypi.local:8080/

You are ready to use your raspberryPi with Shinobi as a local NVR solution.