stephendotexe
Posts: 21
Joined: Sat Jun 01, 2013 11:20 pm
Contact: Website

Get rid of your awful CCTV and use Raspberry Pi + Shinobi as a full-featured CCTV project

Fri Aug 17, 2018 9:39 pm

The Raspberry Pi supports hardware-accelerated h264 encoding/decoding, making it a great base for the CCTV "brain" for my NVR cameras.

Shinobi (https://shinobi.video/) is an open-source CCTV software which natively supports the Raspberry Pi. If you've ever futzed around with commercial CCTV software, you'll see instantly how much better Shinobi is.

You can read more about my setup on my blog here: http://www.heystephenwood.com/2018/08/s ... i-3-b.html

I'm able to support 2x 1080p@30fps and 2x 720p@30fps cameras on a single Raspberry Pi 3 B+ with active cooling. I can probably push it harder but I ran out of cameras.

The biggest bottleneck for me was storage. Thankfully I have a NAS where I can upload/store all of the captured video. Even a 64GB card fills up fast because of how much traffic some of my cameras receive.

The setup

My setup includes 4 cameras: 2x 1080p@30, and 2x 720p@30. I have them monitoring for motion and recording. The RPI is able to handle this workload with surprisingly little power usage.

In order for this setup to work, there's a few conditions that must be met:
  • No transcoding. It's simply too CPU intensive even with hardware-accelerated h264_omx encoder. For any recording/streaming you'll need to set the video codec to "copy" (or possibly the jpeg API).
  • Depending on the camera quality settings, you'll need to bump the GPU memory share up to 256MB. Even to me this seemed too high, but without it I was getting mmal decoding errors with more than 2 1080p@30 NVR camera.
  • For any decoding you'll need to use the hardware-accelerated h264_mmal codec. Without specifying this codec there will be too much CPU usage. Using MMAL ensures that the heavy lifting of deciding the h264 stream is done on the GPU.
  • Real 2.5a power supply. Your RPI needs all of it.
  • (Optional) Active cooling. My RPI case has a small fan hooked up the 3v power supply. I have small heatsinks attached to the SoC.
Also, despite what I read about in a lot of up-to-date blogs, you do need not need to recompile ffmpeg on the raspberry pi to take advantage of hardware-accelerated h264 encoding/decoding. The current version of ffmpeg installed via apt fully supports these codecs:

Code: Select all

# ffmpeg
ffmpeg version 3.2.10-1~deb9u1+rpt2 Copyright (c) 2000-2018 the FFmpeg 

# The encoder to use (if any -- see comment about "copy")
$ ffmpeg -encoders | grep omx
 V..... h264_omx             OpenMAX IL H.264 video encoder (codec h264)

# The decoder to use
$ ffmpeg -decoders | grep mmal
 V..... h264_mmal            h264 (mmal) (codec h264)
 V..... mpeg2_mmal           mpeg2 (mmal) (codec mpeg2video)
 V..... mpeg4_mmal           mpeg4 (mmal) (codec mpeg4)
 V..... vc1_mmal             vc1 (mmal) (codec vc1)
Let me know here or on the blog if you have any questions and I'd be more than happy to answer them!

http://www.heystephenwood.com/2018/08/s ... i-3-b.html

Sp00kie13
Posts: 9
Joined: Sun Sep 03, 2017 1:21 pm

Re: Get rid of your awful CCTV and use Raspberry Pi + Shinobi as a full-featured CCTV project

Sun Nov 03, 2019 3:54 pm

Hi stephen

tried following setup instructions in Shinobi. I can get the server up and running no problem but cannot get the server to recognize the mmal pinoir camera attached to my pi 3b.

do you have a walk-through or can you point me in the right direction here?

thanks

Return to “Other projects”