2 weeks ago
My $5/month NVR solution for two G3 flex cameas
Used Products
×1
Location
Canterbury 7999, New Zealand
Description

Here is how I achieved a NVR for $5/month which gives me 2 X G3 Flex full HD camera streams recording on motion events, plus 24x7 timelapse at 10 second intervals that goes back around 3 days per cam.

 

I used Linode.com and hosted the VM in their Tokyo DC because it is closest to where I am in New Zealand. I stood up the smallest VM which is called a Nanode 1GB. It's USD$5/month with 1 CPU, 1GB RAM and 25GB SSD. It comes with 1TB transfer per month, but traffic inbound to the server doesn't count towards the total.

 

The cameras each send approx 3.25Mbit/sec constant stream of encrypted video to the server, so approx 7Mbit/sec at the server end constant inbound. This represents approx 2TB/month per camera.

 

I used Ubuntu 16LTS image and installed unifi-video then set up the cameras and motion recording but not full-time recording. I also enabled the RTSP stream output for each camera on the server. I then set up two instances of ffmpeg which connect to the RTSP feeds and capture single-frame jpeg images at a rate of one per 10 seconds. At the end of each hour another script takes the last hour's jpegs and uses ffmpeg to creates a timelapse mp4 video of the hour before deleting the jpegs.

 

Further scripts clean up the timelapses videos once they get larger than 1500MB per camera (deleting the oldest first). The timelapse videos are made available to my viewer using apache2.

 

So all in all it fits nicely within the 25GB SSD that comes with the Nanode. The unifi-video server keeps the available HD at 10GB (the minimum it can be set to) and the two timelapse folders sit at a constant 1500MB each (around 3 days). The number of days of motion-video (full HD) depends on how many motion events.

 

My internet connection is fibre based and flat-rate. The 7Mbit/sec constant outbound load is unnoticeable to us in terms of the other things we use the connection for.

 

So that's my $5/month NVR solution (not counting our internet connection, which we already had)!

 

If anyone wants any info on specifics around how any of it is set up, just ask.

 

*** UPDATE - please see my comment posting below. I have ditched the RTSP streams and changed to using the API to pull the stillframes and this has caused almost an order of magnitude decrease in CPU usage. I have also created a github repository with the scripts and necessary pre-requisite steps to set up a host. 

 

Screen Shot 2018-12-01 at 11.18.34 PM.png

 

 

 

Screen Shot 2018-12-01 at 11.08.29 PM.png

 

Screen Shot 2018-12-01 at 11.15.39 PM.png

 Screen Shot 2018-12-01 at 11.17.58 PM.png

 

 

My $5/month NVR solution for two G3 flex cameas

by 2 weeks ago - last edited yesterday

Here is how I achieved a NVR for $5/month which gives me 2 X G3 Flex full HD camera streams recording on motion events, plus 24x7 timelapse at 10 second intervals that goes back around 3 days per cam.

 

I used Linode.com and hosted the VM in their Tokyo DC because it is closest to where I am in New Zealand. I stood up the smallest VM which is called a Nanode 1GB. It's USD$5/month with 1 CPU, 1GB RAM and 25GB SSD. It comes with 1TB transfer per month, but traffic inbound to the server doesn't count towards the total.

 

The cameras each send approx 3.25Mbit/sec constant stream of encrypted video to the server, so approx 7Mbit/sec at the server end constant inbound. This represents approx 2TB/month per camera.

 

I used Ubuntu 16LTS image and installed unifi-video then set up the cameras and motion recording but not full-time recording. I also enabled the RTSP stream output for each camera on the server. I then set up two instances of ffmpeg which connect to the RTSP feeds and capture single-frame jpeg images at a rate of one per 10 seconds. At the end of each hour another script takes the last hour's jpegs and uses ffmpeg to creates a timelapse mp4 video of the hour before deleting the jpegs.

 

Further scripts clean up the timelapses videos once they get larger than 1500MB per camera (deleting the oldest first). The timelapse videos are made available to my viewer using apache2.

 

So all in all it fits nicely within the 25GB SSD that comes with the Nanode. The unifi-video server keeps the available HD at 10GB (the minimum it can be set to) and the two timelapse folders sit at a constant 1500MB each (around 3 days). The number of days of motion-video (full HD) depends on how many motion events.

 

My internet connection is fibre based and flat-rate. The 7Mbit/sec constant outbound load is unnoticeable to us in terms of the other things we use the connection for.

 

So that's my $5/month NVR solution (not counting our internet connection, which we already had)!

 

If anyone wants any info on specifics around how any of it is set up, just ask.

 

*** UPDATE - please see my comment posting below. I have ditched the RTSP streams and changed to using the API to pull the stillframes and this has caused almost an order of magnitude decrease in CPU usage. I have also created a github repository with the scripts and necessary pre-requisite steps to set up a host. 

 

Screen Shot 2018-12-01 at 11.18.34 PM.png

 

 

 

Screen Shot 2018-12-01 at 11.08.29 PM.png

 

Screen Shot 2018-12-01 at 11.15.39 PM.png

 Screen Shot 2018-12-01 at 11.17.58 PM.png

 

 

{"location":{"title":"Canterbury 7999, New Zealand","placeId":"ChIJE5yTfgqqK20RRrV7eN11WQg"},"addedProducts":[{"id":"unifi-video-g3-flex-camera","count":1}],"solved":"","numbers":"","description":"","mainImage":"184408iD4F31FDA7ECC916D"}

Screen Shot 2018-12-01 at 11.08.29 PM.png
Screen Shot 2018-12-01 at 11.15.39 PM.png
Screen Shot 2018-12-01 at 11.17.58 PM.png
Screen Shot 2018-12-01 at 11.18.34 PM.png
Comments
by
2 weeks ago

How can the NVR software get by with 1 gig of RAM?  Minimum system reqs is 4 gig.

by
2 weeks ago

It would be awesome if you'd publish your scripts and setup instructions on github for others to use.

by
2 weeks ago

LLigetfa, a lot of times, the minimum isn't actually the minimum. You can get by with less under some situations. Now, I'm the furthest person from an expert with the NVR, so I can't talk for macgeeknz, but presuming this much, he probably made it work with not only it running on Ubuntu (one of the lighter OS's nowadays) but also with a decent CPU and SSD (which may or may not affect things)

by
Saturday - last edited Saturday

Hes got 512mb swap with ssd backed so that would certainly help if its spils over 1 gb. I'd love to see the code of this setup very interesting design here.

by
yesterday

Hi agian. Sorry for the long delay before I replied. I had to learn github to help evildog! Hey @evildog, check out this repository:

https://github.com/macgeeknz/unifi-video-timelapse

 

I've made some changes. First up, the repsitory is set up for just one camera. But it's fairly easy to extend it to two or more. Just clone the relevant scripts.

 

Secondly, I've given up on using ffmpeg to watch the rtsp stream. Turns out that it misses keyframes and the timelapses can get all distored images. Even better though, I found a way to pull snapshot jpegs from the api (using jq and curl) every 10 seconds and the resuts from those are pefect. I still use ffmpeg and imagemagick to create the timelapse. I've sped up the timelapse to 10 frames per second (with each frame covering 10 seconds). It means you can watch an hour's worth in 30 seconds but still singe-frame step to any 10 second period within the movie easily. Extra bonus, pulling the images via the api is almost an order of magnitude less CPU intensive, meaning much lower spikes (my dual-cam setup now averages about 20% cpu on a nanode).

 

In answer to @LLigetfa, I wasn't actually aware of the 4GB RAM recommendation when I started this, but what I can tell you is it works just fine on a 1GB nanode with this timelapse stuff happening for two cameras. The RAM usage generally sits around 500MB and it peaks up to about 950MB when ffmpeg is creating the mp4 files. I do have 512MB SSD backed swap, but it's generally unused. I think the devs were just being very conservative when making their recommendations and covering usage cases with many more cameras than this etc.

 

I hope the github repository with the scripts in it is helpful to someone. I guess I should now as that everyone redirect any further comments and discussion to over to there:

 

https://github.com/macgeeknz/unifi-video-timelapse