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
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 |
- OpenLDAP Installation and Configuration in Ubuntu 12.10/13.04/13.10 And Debian 6/7 : OpenLDAP is a free open source Light Weight Directory Access protocol developed by the OpenLDAP proj...0 comments |
- Configure Your Browser To Use Tor On Ubuntu/Debian/Linux Mint : Tor, The Onion Router, is a network of Virtual Tunnels that allows users to communicate securely and...2 comments |
- How To Upgrade From Ubuntu 13.04 Raring To Ubuntu 13.10 Saucy Salamander : Ubuntu 13.10 Saucy will be released on October 17th. Hope it will come with lot of improvements and ...0 comments |
- Install lamp with 1 command in Ubuntu 12.10, 13.04 Raring Ringtail & LinuxMint13 : Updated: 10/09/2012 :LAMP (Linux, Apache, MySQL and PHP) is an open source Web development platform ...0 comments |
- Twelve Vulnerabilities Have Been Fixed In Ubuntu 12.04, Time To Update : Canonical has released security updates for Ubuntu 12.04 LTS and advices to update your system as so...0 comments |
- TeamViewer 9 Final Has Been Released!
- Twelve Vulnerabilities Have Been Fixed In Ubuntu 12.04, Time To Update
- OpenLDAP Installation and Configuration in Ubuntu 12.10/13.04/13.10 And Debian 6/7
- Configure Your Browser To Use Tor On Ubuntu/Debian/Linux Mint
- Setup A Full Featured ITIL Management System Using Integria IMS On CentOS 6
- Install LibreOffice 4.1.3 in Elementary OS ‘Luna’
- How To Install Simple Scan in Crunchbang ‘Waldorf’
- Selene Media Encoder: Convert Audio, Video Files To Most Popular Formats
- Linux Kernel 3.12.2 Is Available For Download! Install / Upgrade Instructions
- CentOS 6.5 Has Been Officially Released!
This work by unixmen.com is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Copyright © 2008-2013 Unixmen.com .