My home surveillance system is quite basic and I like to keep it that way, but the current solution keeps crashing or my server dies which makes me do manual surveillance of the surveillance system.
Current System
Nyx
Nyx is my old college laptop which runs 24x7 records the camera footage and becomes my NAS at times.
Specs:
- i5-7200U (2 cores 4 threads)
- 8GB DDR4 2133MHz RAM
- 1 TB 5200RPM HDD
- Ubuntu 20
Cameras
I run a total stack of 5 cameras, all from Imou (Ranger 2 and Bullet) as in India it’s hard to get a good camera with clear ONVIF protocol support. My requirements for these cameras are quite simple:
- IP Cam (both over WiFi and LAN)
- Infrared
- ONVIF support
On my first setup with Imou, I realised the camera stream coming on the Imou app was coming from the internet rather than the camera which is on the same network locally. It made me question the whole camera choice but I didn’t have any better alternatives so we fixed it with some networking (next section). I’m not at all interested in my cameras sending data to Chinese servers.
Dahua Config Tool - As Imou is a consumer brand from Dahua, their Config Tool works well for setting IP config to the cameras.
Networking
I have 2 routers in my home, one running off 2.4 GHz and the other on 5 GHz. All the cameras are connected to 2.4 GHz and other devices to 5 GHz. I have disconnected the internet access on the 2.4 GHz router, so the cameras are isolated. Both networks have different DHCP servers and different IP ranges they use to assign IP addresses to devices.
Nyx connects to two networks (one over LAN and the other over wifi) and makes sure it has access to camera streams and also the internet which makes it ideal for me to save the streams on Nyx and access the live view easily as well. Also, Nyx has Tailscale up and running which allows me to remotely access the streams and recordings.
Before going forward, my main internet router (TpLink Archer C80) doesn’t have VLAN support nor a decent enough firewall to disable internet to devices. So yeah, two routers were the only way I could think of. It does get solved in the new setup with the same router.
ZoneMinder
I run the camera stack on ZoneMinder (a pretty complicated tool but gets the job done) and the live stream access on mobile is through ZmNinja (their mobile app). All the cameras run two streams, one high res and the other low. The low res is used for streaming while high res is used for recording. Thanks to the community for figuring out the URLs as Imou doesn’t give them publically.
Challenges
While this system worked quite well for 6 months, I struggled with adding new storage to it, a few cameras were getting disconnected randomly, high memory usage, MySQL complications, no monitoring was there, etc. So I decided to think about this from scratch and make the necessary changes to make this better.
New System
Nyx
I ditched Ubuntu and I’m so glad I did. I am not a fan of apt and Ubuntu’s dependencies make me go crazy. I was a very happy Arch user 5-6 years back, so I decided to go for Manjaro (UI makes things easier). Also, I needed my Nvidia GPU setup to be easy this time (which didn’t happen btw). No more changes on the laptop side.
Frigate & Home Assistant
I researched a few more tools for NVR came across Frigate, and got myself sold to it. Frigate’s main purpose is detection which I plan to have in future so it looked like a good and simple alternative to ZoneMinder. I quickly spun Frigate on Docker and configured it with the IP cameras and boom it’s up and running in less than an hour. The config file makes Frigate easy to add more cameras or modify existing ones.
The setup remains identical, highres stream is used for recording purposes and lowres is used for streaming. One major issue I faced with frigate was, despite the live stream not being consumed anyways I could see the ffmpeg process running in the htop. The recording was coming as RTSP so it can be directly saved to disk but the ffmpeg was required to decode and stream things. After researching a bit, figured out frigate does the decoding 24x7 which is not what I wanted, also disabling the decoding does disable the recording as well which is bad (Frigate has plans to fix this). So quick googling and research, gave me the idea to stream a 2x2 black box on ffmpeg and let it decode that (hardly consumes any CPU) and it worked quite well. My cpu usage dropped from 80% to 30% which was savour for me. When I need actual object detection, I can see what can be done here, right now recording and streaming are required.
Now, recording is sorted but streaming is still a problem. I wanted to try Home Assistant for a long time, and it has plugins to stream RTSP which my camera supports. So I spun up HomeAssistant in Docker and set up an ONVIF camera for all my streams. HomeAssistant app works well for streaming the cameras over Tailscale and recording is working fabulous.
Frigate also restarts the ffmpeg process whenever it crashes, making it save time and effort.
PS: I already have static IP on my cameras using Config Tool, so it makes the config easier as I have to do it in 2 places.
Networking
I had all the setup up and running and the networking was still the same, I was not happy around it as it felt just messy to me. I was this close to buying a NanoPi, flash OpenWRT buying some APs and living a peaceful life but an idea struck buy off Reddit (thanks r/homenetworking). I removed my camera router, got all cameras on my primary router and changed the gateway of the camera to a random IP address (thanks to Dahua Config Tool) and boom they are on the same network but have no access to the internet. I am still not sure why, but this decreased the load on my CPU even more by a big margin. Maybe because now I have a single network interface to stream data from and that’s LAN. No more wifi connections.
Monitoring
I’m still working on the monitoring part and I feel it’s a long run, but I have Prometheus, Grafana and Alertmanager set up on Nyx. Have basic alerts on high system usage and some uptime monitoring on the frigate. Alertmanager has Telegram set up to send me notifications.
Conclusion
Frigate is amazing, runs on low memory and works right out of the box. Would see how it works for my setup, let me know if I can improve some things. I will make the NanoPi + OpenWRT router someday for sure as it has got me excited.