Hi, Geektimes! I want to share my experience in organizing a very low-cost video surveillance at a country house with 3G with the ability to view online and save the archive.
Since I had never come across video surveillance before, I decided to start with a simple one - buy only one 2M camera and then test and see what happens.
I read reviews in the internet, my choice fell on
this copy of the Chinese production. The device broadcasts over rtsp 1920 * 1080 with compression h264 main stream and 540 * 340 second stream.
Buying a device, I assumed that I would find a program for recording video from a camera without any problems even though under Windows, even under Linux. In life, everything was much more complicated.
')
I had a computer with Intel Pentium D (2 core), 1 GB RAM, built-in vidyuha, 250 GB hard. At the time of receiving the camera, lived on this old PC windows XP x86.
There is also an MTS whistle (at the dacha catches 3G), there is a hosting with a VDS server. It is clear that there is no need to talk about high-quality video surveillance with this kind of luggage, but you have to start with something.
So, I started home tests. The first thing that came to mind was to try the well-known service
ivideon . Quickly register, put the soft, one-two-three everything is ready, convenient and simple. It is a pity that such a service imposes significant restrictions on free use, in principle, you can live, but not conveniently. The most sadness is the huge amount of data transmitted by outgoing uplink, for 3G it's a bit too much, you need a good Internet, but it is not and will not be.
ZoneMinderOnce upon a time, they put this software at work, the impression is very good, many settings work well.
Unfortunately, it didn’t come to the installation of this software, since, according to people familiar with the situation, the service is very demanding of resources and on my old computer simply couldn’t take off, and I didn’t want to reinstall Windows. Left in case of emergency, if I find nothing suitable.
Axxon nextApparently harsh software for harsh companies. In the free version up to 4 cameras and more, no restrictions. In the test mode, the entire functionality with all cameras, writes only from 8-00 to 20-00 (or what it is).
To be honest, the usability of the program is very inconvenient, but yes figs with it, we will get used to it. Faced problems: Writes video in one archive in its own format - the video cannot be accessed just like that, it does not work on a PDA (opengl> 1.4 is required). The last 4th version does not work in HP wines, the 3rd one works, but, damn it only from the console, it will not work on the RDP.
XeomaSoftina installed on the old hardware, earned.

In general, the software is not very convenient, but you can get used to it, it's a matter of time.
From the "constructor" you can collect different schemes, logic, add some handlers, actions when an event occurs. But all this makes no sense in the free version, where only 3 modules are available (in the paid cheapest version of these modules already 6). One of them is a camera, one entry in the archive. You can fasten the motion detector, but unfortunately this is not my case - the iron will not pull out, it will not be viewed online (more on this later - it was decided to issue a static image upon request, rather than drive all traffic to the Internet).
The opportunity to edit the frame rate on the screen was also useful for me. Since the rdp + 3g uplink is not fast, the output of the real image simply puts on the dull channel. In the software I set the output to 1 frame per minute, you can set another one more often / rarely
FFMPEGThe latest working version of ffmpeg for Windows XP is
here .
In general, it is very nice when the process is fully controlled, but you need to write a lot of things yourself. Reconnection, rotation, check for freezing and so on. I didn't really want to write myself. But the command, who can use it to capture a stream and write to a file:
D:\ffmpeg\ffmpeg -i rtsp://192.168.1.10:554/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_stream -reset_timestamps 1 -vcodec copy -acodec copy -y -f segment -segment_time 60 -segment_format mp4 "d:\Xeoma\video\vid-
Sadness melancholy with software gentlemen. Sadness ...
But let's go back to the scheme of including all this disgrace and see what the principle we want and what can we do?
We have: 3g whistle. In fact, all mobile operators for a long time no longer provide dynamic IPs for whistles, but give gray addresses and pull. To get through the Internet on a computer with 3G is possible only through VPN.
But we want to do everything cheaper. Which tariff to choose? Which operator to choose (catches 3G at my dacha with all operators - lucky)? There is no desire to pay for 600 rubles per month for the whistle. I looked at the tariffs of all operators - about all the same.
The solution was simple. It turns out that my MTS has a “Share an Internet” option or something like that. The point is that you pay 100 rubles per month and share your Internet on the tariff with a different number. This is the path I took.
Setting up a vpn server on debian is
very easy .
In the BIOS of the company, we set up auto power-up when power returns, tune the MTS connection via standard means (like a dial-up modem with a call to * 99 #) and set up raising vpn after raising the MTS connection. READY! There is a connection, VPN holds. You can work.
To administer the server, it is enough to connect through the sss server tunnel to port 3389 (rdp) and there is no need to set 3389 from the WinHP to the outside with port forwarding through the hosting.
Since it was decided that we will not upload the entire archive, the question remains - how to organize online viewing.
I did this:
On the computer with the Windows set the recording of the main stream continuously, and an additional I rake every 30 seconds. This is done in order to quickly find a sample time of interest, and then slowly and slowly pull video files on 3G. Apache installed on the server, php set it on the directory with the video photo and turned on the option to index the contents of the directory.
On the hosting receiver (where we connect on vpn) we configure port forwarding:
ProxyPreserveHost On #ProxyRequests Off ProxyPass / http://192.168.1.30/ ProxyPassReverse / http://192.168.1.30/
Where
192.168.1.30 is the address we received from pptpd.
To display files from a stream, I chose the following concept:
Online we will miss one frame with additional stream in quality below 2MP. To view the picture in high definition, we can rotate the main stream files once a minute (later it will also be easier to download files) and we will capture the frame from the last completed video. Thus, the maximum lag of HD pictures will be 2 minutes, which is normal.
To get snapshots from a video file, use the following php code:
shell_exec ("D:\scripts\convert.cmd $file");
Well, the process of getting snapshots:
D:\ffmpeg\ffmpeg -y -loglevel 0 -i %1 -ss 00:00:1.1 -r 1 -vframes 1 D:\Xeoma\last.jpeg
Total cost:
- Camera 2500
- Inet 100r / month
- Consumption of electricity by the computer 24/7 = 100W * 24 * 30 * 4p / kWh = 288p / month
- Old comp (was available) = 3000r
- VDS Hosting with the ability to receive vp (was) = ​​2400 / year
Probably not cheaper :)
I hope this article will be useful to anyone.