08/20/2017
My First Unifi Video Setup with Raspberry Pi Monitor
Description

I was looking for a home video solution where I didnt have to pay a subscription fee to record video. My friend recommended Unifi. After some research and help from the forum, I purchased and installed the following:

 

Ubiquiti Networks UniFi G3 Series 2MP Outdoor Bullet Camera (5-Pack)

Ubiquiti Networks UniFi G3 Series 1080p Dome Camera

Ubiquiti Networks UniFi UVC-NVR with 500GB HDD

Ubiquiti Networks EdgeSwitch 8-Port 150-Watt Managed PoE+ Gigabit Switch with SFP

Ubiquiti Networks TC-PRO TOUGHCable PRO Level 1 Outdoor CAT5e Cable (1000')

Ubiquiti Networks TOUGHCable Connectors (Pack of 100)

 

After watching countless videos on youtube, the install went relativly easy. I am a programmer by day so the IT background helped.

 

setup.png

 

Since the NVR doesn't support HDMI or VGA out, I found a thread here on using a raspberry pi to output to HDMI. I dug out an old raspberry pi 2 Model B, tweaked the code, added a background and I now have a 24/7 monitor for my office:

 

rPi-unifi.png

 

Code to run Raspberri Pi Monitors:

#! /bin/sh
# /etc/init.d/play6ubntcams

### BEGIN INIT INFO
# Provides:          play6ubntcams
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Loads a matrix of 6 RTSP streams
# Description:       Loads a matrix of 6 RTSP streams
### END INIT INFO


# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting the 6-Camera Matrix"
    echo "To configure the matrix, run 'sudo nano /etc/init.d/play6ubntcams'" 


    # Set the RTSP URIs here for each camera.
    # You can also modify the size of the windows for each stream by editing the --win parameter (XStart YStart XEnd YEnd)

    screen -dmS row1col1 sh -c 'omxplayer --win "0 0 637 375" -n -1 rtsp://url1; exec bash'
    screen -dmS row1col2 sh -c 'omxplayer --win "637 0 1274 375" -n -1 rtsp://url2; exec bash'    
    screen -dmS row1col3 sh -c 'omxplayer --win "1274 0 1911 375" -n -1 rtsp://url3; exec bash'

    screen -dmS row2col1 sh -c 'omxplayer --win "0 375 637 750" -n -1 rtsp://url4; exec bash'
    screen -dmS row2col2 sh -c 'omxplayer --win "637 375 1274 750" -n -1 rtsp://url5; exec bash'
    screen -dmS row2col3 sh -c 'omxplayer --win "1274 375 1911 750" -n -1 rtsp://url6; exec bash'

    fbi -t 5 -a --noverbose *.png; exec bash

    ;;
  stop)
    echo "Stopping 6-Camera Matrix"
    # kill all stream screens:
    killall omxplayer.bin
    ;;
  *)
    echo "Usage: /etc/init.d/play6ubntcams {start|stop}"
    exit 1
    ;;
esac

exit 0 

 I am actually impressed with the stream quility with the Pi. There is no lag and video stream looks good. 

 

** Edit **

 

After having the Raspberry Pi 2 running for about a month, it became pretty clear the Pi is too under powered to stream 6 cameras. The first thing I noticed was the video streams were about 4-5 seconds behind. Another issue was after about 6 hours, the Pi would crash. The solution was to upgrade to a Raspberry Pi 3 B. The rPi 3b can handle 6 cameras, but the Wifi cannot, even on the lowest resolution I was getting crappy video. However after a few days running over ethernet, the streaming is good and the delay is ~1 second. No crashing either. I can live with that.

 

My First Unifi Video Setup with Raspberry Pi Monitor

by ‎08-20-2017 11:17 AM - edited ‎09-28-2017 02:35 PM

I was looking for a home video solution where I didnt have to pay a subscription fee to record video. My friend recommended Unifi. After some research and help from the forum, I purchased and installed the following:

 

Ubiquiti Networks UniFi G3 Series 2MP Outdoor Bullet Camera (5-Pack)

Ubiquiti Networks UniFi G3 Series 1080p Dome Camera

Ubiquiti Networks UniFi UVC-NVR with 500GB HDD

Ubiquiti Networks EdgeSwitch 8-Port 150-Watt Managed PoE+ Gigabit Switch with SFP

Ubiquiti Networks TC-PRO TOUGHCable PRO Level 1 Outdoor CAT5e Cable (1000')

Ubiquiti Networks TOUGHCable Connectors (Pack of 100)

 

After watching countless videos on youtube, the install went relativly easy. I am a programmer by day so the IT background helped.

 

setup.png

 

Since the NVR doesn't support HDMI or VGA out, I found a thread here on using a raspberry pi to output to HDMI. I dug out an old raspberry pi 2 Model B, tweaked the code, added a background and I now have a 24/7 monitor for my office:

 

rPi-unifi.png

 

Code to run Raspberri Pi Monitors:

#! /bin/sh
# /etc/init.d/play6ubntcams

### BEGIN INIT INFO
# Provides:          play6ubntcams
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Loads a matrix of 6 RTSP streams
# Description:       Loads a matrix of 6 RTSP streams
### END INIT INFO


# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting the 6-Camera Matrix"
    echo "To configure the matrix, run 'sudo nano /etc/init.d/play6ubntcams'" 


    # Set the RTSP URIs here for each camera.
    # You can also modify the size of the windows for each stream by editing the --win parameter (XStart YStart XEnd YEnd)

    screen -dmS row1col1 sh -c 'omxplayer --win "0 0 637 375" -n -1 rtsp://url1; exec bash'
    screen -dmS row1col2 sh -c 'omxplayer --win "637 0 1274 375" -n -1 rtsp://url2; exec bash'    
    screen -dmS row1col3 sh -c 'omxplayer --win "1274 0 1911 375" -n -1 rtsp://url3; exec bash'

    screen -dmS row2col1 sh -c 'omxplayer --win "0 375 637 750" -n -1 rtsp://url4; exec bash'
    screen -dmS row2col2 sh -c 'omxplayer --win "637 375 1274 750" -n -1 rtsp://url5; exec bash'
    screen -dmS row2col3 sh -c 'omxplayer --win "1274 375 1911 750" -n -1 rtsp://url6; exec bash'

    fbi -t 5 -a --noverbose *.png; exec bash

    ;;
  stop)
    echo "Stopping 6-Camera Matrix"
    # kill all stream screens:
    killall omxplayer.bin
    ;;
  *)
    echo "Usage: /etc/init.d/play6ubntcams {start|stop}"
    exit 1
    ;;
esac

exit 0 

 I am actually impressed with the stream quility with the Pi. There is no lag and video stream looks good. 

 

** Edit **

 

After having the Raspberry Pi 2 running for about a month, it became pretty clear the Pi is too under powered to stream 6 cameras. The first thing I noticed was the video streams were about 4-5 seconds behind. Another issue was after about 6 hours, the Pi would crash. The solution was to upgrade to a Raspberry Pi 3 B. The rPi 3b can handle 6 cameras, but the Wifi cannot, even on the lowest resolution I was getting crappy video. However after a few days running over ethernet, the streaming is good and the delay is ~1 second. No crashing either. I can live with that.

 

Comments
by
on ‎08-20-2017 02:32 PM

 

I have these running at a couple of my customers (the Raspberry Pi as a viewer) and I like the added touch with the "fbi" command, to fill up the spare space with the background image. I can place some very appropriate branding there. I like those small details!

by
on ‎08-21-2017 11:37 PM

Did anyone try to run a script like this on the NVR locally? The HDMI is operational, it just does not show anything interesting...

by
on ‎08-22-2017 04:08 AM

I dont think it will work. From what I understand; correct me if I am wrong, the NRV applicance is running its own flavor of linux e.g. Linux version 3.18.45-ubnt (bdd@builder) (gcc version 4.7.2 (Debian 4.7.2-5) ) and a X Window layer is not installed. More here.

I would have paid an extra $200 for a better CPU/RAM and display capablilies. But if it was that important to me, I would have built my own rig that could handle the load. Nevertheless, for ~$30 USD, the Pi is doing a nice job of running the 6 streams. For me this is OK. I am sure if you have more that 6, there might be issues streaming. But you can always mod the code on the Pi to cycle 6 views at a time.

 

Some benifits of using a Pi over the NVR with output

 

  • The Pi is so small, I can attach it to the back of the monitor. Do I want the NVR close to my monitor?
  • The NVR can be hidden incase of a break in. If someone breaks in and steals the NVR, it was like I had no surveillance at all.

 

Just my 2 cents...

 

by
on ‎09-01-2017 04:54 AM

Hello,

this is nice, I would like also use this script or program, could you please provide all needed files or write her all steps to do ?

 

thank you.

 

Vc.

by
on ‎09-01-2017 06:08 AM

This assumes you have a raspberry Pi 2 or higher already up and running. If not, google. There are a million tutorials on how to set one up.

 

Here it is from memory...

 

sudo apt-get update -y && sudo apt-get upgrade -y && reboot

Install Screen and fbi

 

sudo apt-get screen -y && sudo apt-get fbi -y && reboot

Log in to your NVR or camera and turn on rtsp streaming for each camera. Make a copy of the rtsp URL

 

Create the Script and save play6ubntcams

sudo nano /etc/init.d/play6ubntcams

 

#! /bin/sh
# /etc/init.d/play6ubntcams

### BEGIN INIT INFO
# Provides:          play6ubntcams
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Loads a matrix of 6 RTSP streams
# Description:       Loads a matrix of 6 RTSP streams
### END INIT INFO


# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting the 6-Camera Matrix"
    echo "To configure the matrix, run 'sudo nano /etc/init.d/play6ubntcams'" 


    # Set the RTSP URIs here for each camera.
    # You can also modify the size of the windows for each stream by editing the --win parameter (XStart YStart XEnd YEnd)

    screen -dmS row1col1 sh -c 'omxplayer --win "0 0 637 375" -n -1 rtsp://url1; exec bash'
    screen -dmS row1col2 sh -c 'omxplayer --win "637 0 1274 375" -n -1 rtsp://url2; exec bash'    
    screen -dmS row1col3 sh -c 'omxplayer --win "1274 0 1911 375" -n -1 rtsp://url3; exec bash'

    screen -dmS row2col1 sh -c 'omxplayer --win "0 375 637 750" -n -1 rtsp://url4; exec bash'
    screen -dmS row2col2 sh -c 'omxplayer --win "637 375 1274 750" -n -1 rtsp://url5; exec bash'
    screen -dmS row2col3 sh -c 'omxplayer --win "1274 375 1911 750" -n -1 rtsp://url6; exec bash'

    fbi -t 5 -a --noverbose *.png; exec bash

    ;;
  stop)
    echo "Stopping 6-Camera Matrix"
    # kill all stream screens:
    killall omxplayer.bin
    ;;
  *)
    echo "Usage: /etc/init.d/play6ubntcams {start|stop}"
    exit 1
    ;;
esac

exit 0 

Test it:

 

To start:

/etc/init.d/play6ubntcams start

To stop:

/etc/init.d/play6ubntcams stop

Grant permissions:

sudo chmod 755 /etc/init.d/play6ubntcams

Make it run at start up

sudo update-rc.d play6ubntcams defaults

Please note, for fbi to load your background images (.png), place them in a directory e.g. /home/pi/background

 

Change this line:

 

fbi -t 5 -a --noverbose *.png; exec bash

To

fbi -t 5 -a --noverbose /home/pi/background/*.png; exec bash

You may need to adjust the positions of the screen displays depending on your monitor or resolution. Its a bit of an art tweaking these.

 

Let me know how it goes.

 

by
on ‎09-03-2017 09:42 PM

Hello, thank you for reply, i wiil check it this this week. Br, Vs.

by
on ‎10-29-2017 04:26 AM

Thank you for sharing your knowlege with us.

 

This set up is exactly what we need to teach "mom & pappa" to install security where ever they need it.

 

Would the Raspberry Pi Zero also work?

 

Thanks again!!!!!

by
on ‎10-29-2017 05:36 AM

Happy to help!

 

Althought the Raspberry Pi Zero is dirt cheap, you are going to need an ethernet port. I tried streaming the video over wifi and it was choppy. The wifi could keep up with six cameras.

 

For a mom and pop shop, keep it simple and get a Raspberry Pi 3 wth a nice case. Works good.

 

 

 

by
on ‎10-29-2017 05:43 AM

DUH, you are right, Ethernet, completely forgot about that, great answer.

 

Thanks again for sharing PhillyNJ, hey are you located in NJ??

by
‎10-29-2017 07:35 AM - edited ‎10-30-2017 01:33 PM

Yes, Jersey shore. You?