Weekend hack: surveillance on the cheap

Some time ago I bought a few Foscam MJPEG cameras and installed them in our apartment, originally for baby monitoring, and I wanted to set up a proper security surveillance system.  I already have a Netgear ReadyNAS box, so I thought this should be easy.  However, I soon found out that video surveillance solutions from major NAS vendors (e.g., Netgear, QNap, Synology) require per-camera licenses, in the range of $50-60/camera.  That would be over $200 to enable functionality already present in the device!  Although this is already an order of magnitude cheaper than hardware from traditional NVR (network video recorder) vendors, it still felt unreasonably high. Oh, and Foscam cameras still aren’t supported by ReadyNAS Surveillance.  There used to be a KMotion port for ReadyNAS, but it disappeared around the time Netgear’s official solution came out on the market.  Since ReadyNAS is almost Debian (with customizations), I gave installing KMotion from source a shot, but after an afternoon fiddling with custom configurations as well as tweaks for the low-power Atom CPU, I gave up.

Perhaps the NVR industry is ripe for “disruption”, but I wasn’t willing to wait. Last time I did that (for car stereos) was almost three years ago… and I’m still waiting.  Luckily, an NVR is a much simpler build than a custom car stereo (this was enough for me, thank you :).  There are several low-cost hardware options and ZoneMinder is a great open-source surveillance system that was originally built to scratch an itch (the original author’s power tools were stolen from his garage, and he couldn’t find any reasonably-priced commercial surveillance solutions he liked).  Here is what I got after about a day:

Cubieboard NVR

In addition to some familiarity with installing Linux, a 3D printer, and my case design from Thingiverse, you’ll also need:

Total cost comes to $120 if you have some spare parts around, or about $140 if you get everything and add shipping too. That’s about half the price of just software licenses for a NAS box, and an order of magnitude cheaper than NVR boxes in the market.  Plus, there’s CPU cycles to spare, for more cameras, and it leaves the ReadyNAS Atom CPU free to handle its main tasks (file and media serving).

Although I love the Raspberry Pi and already have a couple for various tasks, I went with the Cubieboard since it has a much more powerful CPU (AllWinner A20 dual-core ARM) and built-in SATA, for just $20 more.  Adding a powered USB hub and SATA-to-USB adaptor to a RasPi would probably have cost more (plus require funky wiring solutions); the Cubieboard was mostly plug-and-play.

The A20 can handle all four cameras in “modect” mode (motion detection triggered recording) at 1fps with one alarm zone per camera, without problems.  The load average can be high (between 0.5 and 1.5) probably due to the continuous I/O, but actual utilization per core seems to peak around 20-25% and is typically in the single digits.  Not bad at all for a low-power (10W max) single-board computer!

There are several Linux distributions for the Cubieboard (including Android) and the documentation is a bit messy, so I installed Linux a few times before I settled with Cubian (basically Debian Wheezy, in the spirit of Raspbian) which is great.  It can be installed on either an SD card or built-in NAND flash (I went with the former).  There are already DEBs for ZoneMinder, so this is a fairly standard Linux install.  The only additional steps were moving data directories for ZoneMinder and MySQL, as well as temporary files and logs (to minimize flash wear), over to the hard drive; see brief instructions on Thingiverse.

If you have a 3D printer and some basic Linux skills, perhaps this might save you a few hundred to a few thousand dollars. YMMV with other video formats (e.g., H.264 HD cameras).  Let me know if it works for you.