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

  • 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

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

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

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

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

Install Raspbian on your PI

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

Log into your PI

  • 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

$ 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

  • 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

$ 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

|| 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.