Following the setup of a Cent OS CCTV server, I’ve been using Raspberry Pi’s as video sources. But what if there was a Raspberry Pi in perfect situ for a CCTV camera, but was already in use as a media player?
A Linux system has always had the impression that it is
versatile, so this should be an achievable task. A barrier would be how to get
this done with the operating system installed, in this case it is LibreElec, an
OS with the tagline “Just enough OS for Kodi”. Therefore, it would be more of a
challenge than a usual Debian install.
The team at LibreElec saw this type of thing coming, and included the Docker service as a Kodi addon to allow the curious tinkerer to add more than Kodi to a Pi.
If you have the LibreElec based Pi in the opportune
placement to add a camera, here is how to add Mjpeg streaming capabilities…
If you’d ever searched for Raspberry Pi projects that
involved a camera then the results would certainly include Motioneye OS, an
easy to use self-contained operating system that is truly (write then) plug and
Looking for a CCTV project earlier this year I too was drawn in by this, and with my small abundance of RPi spares it was the cheapest choice, using a couple of RPi 3B+ for video, and a Zero W for time-lapse image capture. All processing was self-contained on each Pi with capture data passed over via SMB to a Windows file share.
This worked, but had a couple of problems that prevented it
from being trustworthy. Firstly, it stops recording video after a few days of
uptime, by creating empty files. And secondly the time-lapse camera seemed to
reset every few minutes that created in white out image capture as the camera’s
exposure setting recalibrated, ruining a time-lapse video.
Looking wider there was also the performance issue. In
Motioneye OS’ default state of managing all features, the highest FPS seemed to
max at 15 fps even on the Pi 3B+. Forums suggest this is due to the motion eye
daemon handling all the image processing in software, putting a strain on the Pi’s
The idea and goal is to move the processing and IO
responsibilities to my server, which would be far more capable than the then
latest available RPi, and as I have chosen Cent OS to be my go-to Linux OS of
choice, this is what I’ll be using.
A gateway to make this possible is an option in Motioneye OS, Fast Network Camera. This when set relinquishes the Pi of all processing duties and serves to just stream the camera capture as best as possible via MJPEG.
Here’s how to set up Motioneye on a Cent OS server to be a central data hub for a network of RPi Motioneye OS cameras.
For years, since it was XBMC on the original Pi I have been using OSMC as my Raspberry Pi media player. And following on from a whole home Pi redeployment for to include a CCTV system the latest installment was to install OSMC to two Raspberry Pi 3A+.
Raspberry Pi 3A+
The Pi 3A+ plus is the cut down little brother to the latest
3B+ much akin to the original Pi B and A models. Both have the same quad-core ARM
v8 processor, Broadcom Videocore-IV GPU and importantly the 2.4GHz and 5GHz
802.11b/g/n/ac Wi-Fi module for faster and stable WIFI out of the box. What’s cut
down is the RAM, halved at 512MB, USB ports are reduced to one due to the removal
of the onboard USB and gone is the ethernet port.
All the power without the ports make its perfect as a media player,
all that’s needed to connect is the HDMI, with remote control provided via a CEC
The issue with OSMC
Here are the issues I experienced with OSMC on the Pi3A+,
this is in no way a snarl at the developers who are doing an amazing job. I
believe the 3 A+ is still a new and niche model so it’s understandable that development
is slow for this product. I’m just hoping this will eventually be looked into and
resolved, and putting it out there in case others have the same issue. Performance
on the 3B+ is still exceptional.
From boot, selecting a 720p file (via Samba and h264 encoding)
is fine, with subsequent auto-play files playing with no issues. However, with the
next selection the issues start, selecting a file loads it but doesn’t play, having
to go to the main menu and selecting Full-Screen to play the file. But then it buffers
constantly. On the third play this workaround fails, and selecting Full-Screen results
in a black screen.
In addition, even from boot any 1080p content fails to play with
a black screen in its place, and playing h265 encoded files results in an
immediate system crash.
480p content remains unaffected and plays perfectly.
LibreELEC to the rescue
Without resorting to buying a 3 B+, your media experience can still be made on 3 A+ by using LibreELEC, an alternative to OSMC that has the same goal of getting Kodi on the Raspberry Pi.
A little treat when ordering the latest Raspberry Pi was to add a camera module to it, at a price of £7 for the Noir (Not French, just meaning No Infrared filter) it was easy to justify getting even if there was not a set purpose to it.
For the price the Pi Noir camera was generous on the specs, with a 2592 x 1944, 5 Megapixel sensor it seemed capable of capturing high detail images. However, the 5Mp tagline applies to still images only, with video capped at a still respectful 1920 x 1080p.
The difference between the Noir and standard camera module is the lack of an IR filter on the lens, resulting in some washed out colours in daylight but still acceptable in a surveillance capacity, but has the ability to capture images in darkness with help of separate Infrared lighting.
Using the camera module on the Pi is pretty straight forward, connecting is done via a ribbon cable plugged into a dedicated port on the Pi board.
With the cooler outdoor temperatures, a bug in my original code for the temperature display has cropped up:
The DS18B20 returns temperatures with up to three decimal places, with the decimal point omitted, therefore a temperature of 10oC would be shown as 10000 by the sensor. To deal with this and for the display to show the temp to one decimal, I used this code:
About fifteen years ago I did Electronics as a course in college, and at the time my younger self didn’t fall in love with the topic, set down to a culmination of issues.
Now with time at hand and a rejuvenation I felt when getting to grips with the Raspberry Pi I thought it time to get involved again. I must stress that this time these are baby steps, and the Raspberry Pi helps me as it does most of the work for you, with any electronics added considered to be more of a peripheral rather than a self-sustained product.
Nothing grand to start with, but as a first project I thought to combine a 20×4 LCD display with two DS18B20 temperature sensors to monitor indoor and outdoor temperatures. This would replace a cheap display I had been using but was sceptical on its accuracy.
Getting the basics right involved making the device blend in to the current setup without the usual mass of wires protrude. From the last round of the seam ably endless cable management war I used a shoebox base as a stand for the webserver and network switch, with the box hiding the various power bricks and extra cable, with most coming from the Xbox 360. Still having the shoebox lid I thought it would be good to use as a modular part to house the Pi and display.
As requested, this is a guide to taking a Raspberry Pi and turning it into an always on Torrent box, complete and self-sufficient with its own mass storage meaning it needs no help from other computers. Also, as the Pi consumes such little power compared to a full desktop PC, money can be saved by using the Pi for overnight transfers while other computers can remain off.
For this project I recommend a RPi 2, as its powerful enough to perform the transfers up to its maximum 100Mbps network speed, and is a cheaper choice since the RPi 3 superseded it last year. To get started, you need the following hardware:
Raspberry Pi 2 board.
Micro USB wall adaptor – Needs to be capable of 2Amp output.
Micro SD card – Minimum of 8GB, class 6 or above, plus SD adaptor for connecting to a PC.
USB Portable Hard drive – USB powered is preferred, I use a Toshiba Canvio Basics 1TB.
Ethernet Cable – And spare port on the modem/router for internet connection.
A PC – On the same network as the Pi for connection and configuring.
The Pi was designed to as low cost as possible to the user, so apart from the Pi board you may already have everything to run a Pi, and if not these are cheap and easily available online.
During my migration from Windows Server 2003 to Server 2012, I encountered an issue with Kodi on Raspberry Pi and how it connects to the Win 2012 file share. When accessing the server with a Samba file share instead of a prompt for credentials the error message “Operation not permitted” is displayed.
Kodi allows the manual adding of network locations but does not support adding the credentials that are needed to access the location.
Therefore a bit of tweaking is needed to get access to Windows 2012 shares on Kodi.
A great feature of the Raspberry Pi is that it can be fully used as a headless unit, meaning it does not need a monitor, keyboard or any other input device connected. This is great when running it as a server or for automated processes that require the unit to be tucked away.
What is annoying is that setting up the Pi for the first time may need those input devices to be able to configure the network and install applications. Thankfully there is a way to connect to a headless Pi from the start, with it only needing power and Ethernet connection.