Catch Creeps and Thieves in Action: Set Up a Motion-Activated Webcam DVR in Linux
When it comes to webcams these days, most people are using their laptops over desktops. The cameras are centered, integrated, and require no configuring. They're a cinch and usually have great resolution. So, then what do we do with all of those old wired desktop webcams that we've accrued over the years? Even if you still use an external USB one, chances are you're not using it daily, so why not come up with a better use for it?
The answer—home security. We can use those external webcams to beef up our home security with motion-activated surveillance. You could also use it for other situations, such as leaving a child home alone or making sure animals are digging in your trash. This could be coupled with Arduino and Python for some motion-recorded alarm action.
So, for this Null Byte, let's check out how we could secure our home with our Linux computer and that old webcam.
- USB or integrated camera
NOTE: The software we will use supports many other cameras, but this is strictly for readability.
Step 1 Install the Software
Text in bold is a terminal command.
First, we need to install ZoneMinder and all of its dependencies. ZoneMinder is a free utility for Unix-based operating systems that records and monitors your webcam via motion activation. You can even stream them over the internet (the client is a server natively!).
1. Install the dependencies using your package manager. The package names for Ubuntu are:
ffmpeg libarchive-tar-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libjpeg62 libmime-perl libstdc++6 libwww-perl zlib1g
2. After that, get ZoneMinder installed:
3. Extract and install ZoneMinder:
tar zxvf ZoneMinder-1.25.0.tar.gz && cd <new dir> && ./configure && make && install
4. Configure Apache:
sudo ln -s /etc/zm/apache.conf /etc/apache2/conf.d/zoneminder.conf
sudo /etc/init.d/apache2 force-reload
5. Add user to group for use with ZoneMinder:
sudo gpasswd -a <user> www-data
Run the program and get to the video!
Step 2 Video Monitoring
When the service is running, visit your localhost to check if it's working properly.
http://<your IP address>/zm
Then, customize the configuration via the web interface. The first step is to add some cameras.
You can set it to motion-detect recording only, which I highly recommend.
Save the settings and then check out the view. If you forward the port that you run ZoneMinder on, you can view the camera remotely from an internet connection. Remote security for all of about $10. Awesome.
Be a Part of Null Byte!