Howto Turn your old webcam into a motion-detecting security camera in Linux
If you have an old cam that you are not using, you can use it as a security cam. Control Motion is a program that monitors the video signal from one or more cameras and is able to detect if a significant part of the picture has changed; in other words, it can detect motion. The program is written in C and is made for the Linux operating system (using the video4linux interface). Motion is a command line based tool whose output can be either jpeg, ppm fies or mpeg video sequences. Motion is strictly command line driven and can run as a daemon with a rather small footprint.
What motion can do?
- Taking snapshots of movement
- Watch multiple video devices at the same time
- Watch multiple inputs on one capture card at the same time
- Live streaming webcam (using multipart/x-mixed-replace)
- Real time creation of mpeg movies using libraries from ffmpeg
- Take automated snapshots on regular intervals
- Take automated snapshots at irregular intervals using cron
- Execute external commands when detecting movement (and e.g. send SMS or email)
- Motion tracking (camera follow motion – special hardware required)
- Feed events to a MySQL or PostgreSQL database.
- Feed video back to a video4linux loopback for real time viewing
- Lots of user contributed related projects with web interfaces etc.
- User configurable and user defined on screen display.
- Control via browser (older versions used xml-rpc)
- Automatic noise and threshold control
- Motion is a daemon with low CPU consumption and small memory footprint.
Watch some examples here
- For ubuntu / LinuxMint and other debian based systems, you can install motion from terminal using the command:
sudo apt-get install motion
- For Fedora :
RPM for Fedora 12/13/rawhide on x86/x86-64 – Available on RPM Fusion, build without DB support.
Motion and all its dependencies (ffmpeg…) are available on the RPM Fusion repository. Configure the repository and Install motion with
yum install motion
-For other linux distributions download and install the tar package.
- ntar and uncompress the file to the place you want the program installed. Editor recommends placing the motion source file directory in /usr/local.
cd /usr/localtar -xvzf /path/to/motion-3.2.X.tar.gz
- Before to start compiling be sure to have build essential installed:
sudo apt-get install build-essential
- You will now have created a directory called motion-3.2.X. You can rename it to motion (mv motion-3.1.X motion). I recommend creating a symbolic link to the current version. This way you can more easily experiment with different version simply by changing the link.
ln -s motion-3.2.X motion
- Now change to the new directory
- Run configure. You can start with the defaults. If you need to modify the installation parameters you can read the next section.
- Build the code
- Install the code, manual page, etc
- In /etc/motion/ you will find a file called motion-dist.conf. If it is the first time you install Motion – rename this file to motion.conf and edit as a minimum the settings: videodevice, input, norm, frequency, width, height and target_dir. That should get you going.
- Run the program. To enable more features you must modify the config file.
To start motion open terminal and type :
After motion is installed, we have to configure Motion to save captured images in a remote server, to do that we need to install wput a command line FTP client that upload the captured photos by motion , to an remote FTP server. You can install wput by entering the following command into a terminal :
sudo apt-get install wput
- Now you can configure Motion to use wput to upload captured photos by adding the lines bellow to motion.conf file :
And add these lines at the end of the file:
# Command to be executed when a picture (.ppm|.jpg) is saved (default: none)# The filename of the picture is appended as an argument for the command.on_picture_save wput ftp://USERNAME:PASSWORD@REMOTE SERVER %f
Now save and close.
- Finally, we will add Motion to startup automatically start with the server, to do that go to top menu System–>Preferences–>Startup applications then add a new startup program, type in a name for it and then type:
You should now be able to open a web interface for Motion now by typing in localhost:8000 from the server itself or XXX.XXX.X.XXX:8000 from another computers web browser. To view a live stream of your webcam type localhost:8001 from the server itself or XXX.XXX.X.XXX:8001 from another computers web browser. You can change settings from this interface here too, you can even make Motion generate it’s own config files to fit your setup exactly.
Result after installing motion:
Like us on Facebook
We need your assistance to stay live
This week Top Posts
- Top Things To Do After Installing Ubuntu 13.10 'Saucy Salamander' : Ubuntu 13.10 Saucy Salamander will be released on coming October 17th with many new salient featur...0 comments |
- Install Fail2Ban On Ubuntu Server 13.04/13.10 : Introduction Fail2Ban is an intrusion prevention framework written in the Python programming l...0 comments |
- 5 Android Apps that’s Going to Make Running Your Business Less Stressful : Running a business can be very stressful. You have to think about team collaboration, making sure th...0 comments |
- Install Crashplan backup tool in Linux : CashPlan is an automated backup solution that either uses the CrashPlan Central server or any other ...0 comments |
- install Git in Ubuntu : Git is a distributed revision control system with an emphasis on speed. Git was initially designed a...0 comments |
- Install Corosync and Pacemaker On CentOS 6.5 : I will show you in this tutorial how to install your first cluster Corosync and the Linux Cluster Ma...0 comments |
- Install Uget Download Manager In Ubuntu, Fedora, Debian
- Download Elementary OS ‘Luna’ Official Wallpapers
- Install Power Commands 0.1.5 On Ubuntu 14.04/13.10/12.10/12.04
- 5 Android Apps that’s Going to Make Running Your Business Less Stressful
- Puppet agent Install Using Script
- Install Corosync and Pacemaker On CentOS 6.5
- Install Fail2Ban On Ubuntu Server 13.04/13.10
- How To Install Google Chrome in Fedora 20, 19, 18
- How to surf using Tor Browser Bundle
- New Games got Greenlit on Linux by Steam Today!
This work by unixmen.com is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Copyright © 2008-2013 Unixmen.com .