Motion - Mpeg Films F Fmpeg

Generating MPEG films with ffmpeg

The ffmpeg option can generate mpeg films very fast and "on the fly". This means that the mpeg film is growing each time motion is detected.

Some people on the Motion mailing list have had trouble building the ffmpeg package because they did not have the NASM assembler package installed. So pay attention to this if you run into problems.

ffmpeg exists as binary packages for most distributions including RPMs and debian packages.

Ffmpeg is an interesting project. The releases have not been very consistent over time. The official releases are out of date now. So we are forced to take our chance and checkout a version from their CVS server and hope that we are lucky in getting a version that works. See ffmpeg project page. We encourage the maintaners of such an important project to introduce better release schedules in the near future for the benefit of opensource software.

In order to help people finding a version of ffmpeg that works we have started testing the Motion package with a selection of binaries and a CVS snapshot. The CVS source snapshot of ffmpeg which is certified with Motion is available on the Related projects file area on the Motion Sourceforge project

Motion works with the following versions of ffmpeg:
  • ffmpeg-0.4.8. With this release Motion supports mpeg1, mpeg4 and msmpeg4. Lately newer distributions have problems building this 2003 release of ffmpeg so many of you no longer have this option.
  • ffmpeg-0.4.9pre1. Is supported starting from Motion version 3.1.18. With this release Motion supports mpeg4 and msmpeg4 but not mpeg1. The reason is that the ffmpeg team has decided no longer to support non-standard framerates in their mpeg1 encoder library. Also ffmpeg-0.4.9pre1 gives people problems on newer distributions.
  • ffmpeg from CVS. This may work. We cannot continuously monitor and try every time a new source file is checked into ffmpeg. You will have to try.
  • ffmpeg RPMs. Currently each Motion release is tested with the current Livna ffmpeg rpm package for Fedora. See the Download Files page for direct links to the version which has been certified with the latest Motion release.
  • ffmpeg debian binaries. Latest versions from the debian repository for Debian Sarge works fine with Motion.
  • Certified ffmpeg CVS snapshot for latest Motion release is available from the Motion Sourceforge Related Projects file area

The timelapse feature always runs mpeg1 with both ffmpeg 0.4.8 and 0.4.9 and newer. Motion simply creates the timelapse film with a standard mpeg1 framerate. Note : maximum size for timelapse files is 2GB.

In principle Motion can be made to support many other formats. It requires additional coding in Motion. You are welcome to submit patches. All ffmpeg related code is in the source file ffmpeg.c. It is not trivial to do because the ffmpeg libraries not documented at all. All you have is a couple of code examples.

To build ffpmeg from source follow these steps:

Download the ffmpeg and untar it to /usr/local/ffmpeg. Then it should be a simple matter of entering the ffmpeg directory and run the commands

cd /usr/local/ffmpeg
./configure --enable-shared
make
make install

This creates the libavcodec.so and libavformat.so libraries under /usr/local/lib and header files under /usr/local/include/ffmpeg.

You probably need to do one more step.

Make sure you have 'root' privileges for the next steps.

Open the file /etc/ld.so.conf in your favorite text editor.

Add this line of text if it is not already there - otherwise go to the next step (ldconfig).

/usr/local/lib Run the command ldconfig.

Motion should now be able to find the shared libraries for ffmpeg (libavcodec.so and libavformat.so) in /usr/local/lib.

You can also find a pre-compiled binary package (e.g. rpm or deb) and install this. Normally an rpm will place the libavcodec.so under /usr/lib. There are various RPMs available from different repositories. Some need additional RPMs that are actually not needed by Motion but need to be installed to satisfy dependencies. The editor has tried different RPMs of ffmpeg-0.4.8 and they all seem to work.

Motion then need to be built by running ./configure, make and make install. (Note that with earlier versions of motion you had to specify the location of libavcodec. Now configure searches for the shared library in /usr/lib and /usr/local/lib by default.)

Note that if you install ffmpeg from source and already have ffmpeg installed from an RPM, the Motion configure may very well find the binary library from the rpm instead of the sources. Make sure to uninstall any old ffmpeg RPMs before you install ffmpeg from sources.

These are the config file options related to ffmpeg.

This feature uses ffmpegs libavcodec to encode a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Setting this option to 0 disables it.

The feature gives your viewer the chance to watch the day pass by. It makes a nice effect to film flowers etc closeup during the day. Options like frame_rate, snapshot, gap etc have no impact on the ffmpeg timelapse function.

Note that the timelapse format is always mpeg1 independent of ffmpeg_video_codec. This is because mpeg1 allows the timelapse to stop and the file to be reopened and more film appended.

To use this feature you need to install the FFmpeg Streaming Multimedia System.

(renamed from ffmpeg_timelaps to ffmpeg_timelapse in 3.1.14) Supported formats are:

  • mpeg4 or msmpeg4 - gives you files with extension .avi
  • msmpeg4 is recommended for use with Windows Media Player because it requires no installation of codec on the Windows client.
  • swf - gives you a flash film with extension .swf
  • flv - gives you a flash video with extension .flv
  • ffv1 - FF video codec 1 for Lossless Encoding ( experimental )
  • mov - QuickTime ( testing )
  • ogg - Ogg/Theora ( testing )
  • mp4 - MPEG-4 Part 14 H264 encoding
  • mkv - Matroska H264 encoding
  • hevc - H.265 / HEVC (High Efficiency Video Coding)

Timelapse videos have two options.
  • swf - Creates swf file with mpeg-2 encoding.
    If motion is shutdown and restarted, new pics will be appended to any previously created file with name indicated for timelapse.
  • mpeg4 - Creates avi file with the default encoding.
    If motion is shutdown and restarted, new pics will create a new file with the name indicated for timelapse.


See also the section Advanced Filenames where the two additional options ffmpeg_filename and timelapse_filename are defined.

If you want to use this feature you can read about the FFmpeg Streaming Multimedia System

-- KennethLavrsen - 18 Dec 2005
Topic revision: r7 - 14 Apr 2006, PeterKim
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.