I wrote about doing CCTV with zoneminder before, but realized that this might be overkill for many people. If you use less than 4 cameras, you can use the motion package. It works nicely with the Logitech webcam, I connected to my Raspberry.
The camera worked out of the box except that saturation, brightness, etc was way off. You can configure it with the v4l2-utils package. Once you have verified that the picture is OK by using uvccapture, you should be ready to install motion. For my USB webcam, motion worked out of the box. No settings needed at all. For finetuning, I changed the _framerate_ in /etc/motion/motion.conf to 25. Even at that rate, load stayed at 0.00 with abotu 20% CPU usage. Maybe the GPU is doing the bulk of the image processing work.
By default motion captures .swf and .jpg. For me .swf is enough, so I disabled .jpg output with
_outputnormal off. If you want to view your cam over a browser, set _webcamlocalhost off. That way every IP address can access the video stream over a local address like http://10.0.0.19:8081. Further up, you can see my stream. Unfortunately brightness is still a bit too low. I’ll change that later.
Now comes the part where we make our setup really useful. By default motion saves all captures .swf files in the current working directory. When using the init-script, you should save a sensible default output directory. You can change that with the _targetdir parameter in /etc/motion/thread1.conf or motion.conf.
So far so good. By now we have motion running and saving all observations to a directory. That’s OK, as long as we can just SFTP into the raspberry and view the footage. If you want your mum to use it, there needs to be something simpler. I used the PHP-script MotionBrowser by Carlos Ladeira as a simple way to view events by day and hour.
For the script to run, you need to install a web server with PHP-support. Apache is overkill here, so I recommend lighttpd or nginx. I won't go into the details of how to install a webserver, but believe there are many tutorials out there. On top of that you also need mysql to manage the event list. The setup is described on the MotionBrowser site.
Once your webserver is running download motionbrowser.tar and unpack it into /var/www or any other web server root dir. The script worked well, except for serving the .swf-files. When checking download.php, you will notice that the script is actually made to serve .avi-files. We could change that in the motion-settings, but I prefer to stay at .swf because they can be viewed in the browser. Here is what needs to be changed:
In line 53 change avi to swf, so only .swf-files can be downloaded.
[cc lang=“bash” width=“100%” height=“600” noborder=“1” line_numbers=“on” theme=“dawn”] if (strtolower(substr(strrchr($filename,“.”),1)) != “swf”) return; [/cc]
And also replace the whole header part with just one line to simply view the SWF.
[cc lang=“bash” width=“100%” height=“600” noborder=“1” line_numbers=“on” theme=“dawn”] header(‘Content-Type: application/x-Shockwave-Flash’);[/cc]
That should be it. Enjoy your USD 35 surveillance system.
If you don’t like refreshing your browser all the time, you can view the live stream in vlc as well.