Motion: Your Eye in the Sky for Computer Room Surveillance

Your door might be nice, but do you really need 23 hours of video of it standing closed? Use this software to process your security videos to include only the key events, so you can catch entries and exits.

Let's say you have a room full of thousands of dollars' worth of computer equipment. That's probably something you want to keep an eye on, right? With that in mind, you install a network-connected camera. Now, you can surf over to the camera's Web page and see what's going on in the server room at any time of day or night. That's an improvement, but you quickly realize some sort of recording facility is needed, in case you need to figure out who was in the room last Tuesday. So, you start saving the video to another system on the network for possible viewing at a later time. Maybe you write a few scripts to rotate the video after a week or so to keep from filling up your hard drive.

After wading through hours of video to find out who “borrowed” your favorite screwdriver, you realize further refinements are necessary. Wouldn't it be great if the computer could keep only the interesting video and throw out everything else? Enter Motion, a free motion-detection program. Process your video through it, and 24 hours of daily video becomes 15 minutes of video clips documenting every time something moved in that room—technology to the rescue.

The Hardware

Motion works with either standalone netcams, such as those offered by Axis (see the on-line Resources), or any camera connected to a video4linux-compatible video capture card. I concentrate here on using a standalone camera, the Axis 2100, because it's simpler to set up. In any case, you need a Linux system to save the video and to run Motion as well. Motion can require quite a bit of processing power, but a system with a Pentium III CPU or higher should work okay if the machine is dedicated to running only Motion.

Installation and configuration of the Axis camera is straightforward. Pick a location for it in the room you want to monitor, and run power and Ethernet cables. In my experience, a camera mounted slightly above eye level, seven feet up or so, in a corner of the room provides the best coverage. Follow the camera install instructions to assign it an IP address on your network. Then, verify that the camera works by pointing your Web browser at the camera's Web page.

The computer system that is going to save the video and run Motion can be situated anywhere you like. It's probably best to keep it on the same logical and physical network as the camera, for simplicity's sake.

The Software

Any modern Linux distribution should work fine. I use Fedora Core 1 in my setup.

Obtain Motion from the Motion Web site (see Resources). The current version at the time of this writing is 3.1.16. You can use either the RPM supplied on the Motion Web site or build from source. I don't recommend using RPMs or Debian packages from elsewhere as they tend to be out of date and lacking features. Numerous important changes have occurred in Motion development in a few months' time.

The only other software dependency is the ffmpeg library, which Motion uses to generate MPEG videos. You must use the released version 0.4.8 of ffmpeg, as newer development versions do not work well with Motion. Download ffmpeg source (see Resources); you must have ffmpeg built and installed before building Motion. Otherwise, Motion attempts to use an older tool called mpegplayer to create videos. You probably don't have that installed either, so Motion won't work very well.

Building the Software

After you have downloaded both Motion and ffmpeg, untar them in a directory such as /tmp. Then, cd to the ffmpeg source directory and run:

$ ./configure
$ make
# make install

The last command must be run as root.

These commands install the ffmpeg libraries under /usr/local/lib. Then, cd to the Motion source directory and again run ./configure. This time, make sure to check the results. In particular, under Configure Status, FFmpeg Support must say Yes. If not, Motion didn't find the ffmpeg library on your system. This is the number one cause of problems and confusion when installing Motion. Don't continue until you resolve this problem. Figure out where on your system the file is located, and rerun configure in the Motion directory as follows:

$ ./configure --with-ffmpeg=/some/random/path

Once you are able to run configure and see it report FFmpeg Support: Yes, you can build and install motion:

$ make
# make install



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


Keith Daniels's picture

The usage of GNU to refer to Motion has been remove per the authors request.


All the new OSs and windowing systems are oriented towards content consumption instead of content production.

--Steve Daniels 2013


Anonymous's picture

having implemented a motion-based video surveillance system in my company some time ago, i was pleased to see that this excellent piece of software is getting exposure on your pages.

however, i was surprised to see it referred to as "GNU Motion", when in fact the program is not made by the FSF and is only referred to as "motion" everywhere else. what's the dilly-o, yo?

Read the manual man: Motio

Anonymous's picture

Read the manual man:

Motion is an open source type of project. It does not cost anything. Motion is published under the GNU GENERAL PUBLIC LICENSE (GPL) version 2 or later.

First: "It does not cost anyt

Anonymous's picture

First: "It does not cost anything"!=GPL
Second: Gpl!= GNU package. []

Motion is a very good project.
I think that is necessary an adaptative background subtraction.

Indeed, if you can, please

Anonymous's picture

Indeed, if you can, please fix the title as the article is still read by many people who for example happen to google for motion.conf