How to make a time-lapse video from a batch of photos

8,756

The Command Line Method

  • Grab mencoder from the repos.
  • Drop your image files (all image files, the whole image files and nothing but the image files) into a separate directory.
  • Run a mencoder on them, e.g. mencoder mf://*.jpg -mf w=1920:h=1080:fps=25:type=jpg -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=16000:keyint=15:mbd=2:trell -oac copy -o output.avi.

The options above worked well for my images, which were at HD1080 resolution, producing a video at 25fps (the usual TV frame rate in Europe). If you have different needs, you need to tweak the options.

The options after the -mf switch specify the media format.

  • Set w=1920:h=1080 to your desired width and height.
  • Set fps=25 to your desired frame rate.

The options after -lavcopts are the encoder options. These can heavily affect output quality.

  • vbitrate=16000 sets the bit rate to 16 Mbit/s, which I found to work well for HD1080. For lower resolutions, you can lower this value – I have heard reports about vbitrate=8000 giving good results for VGA resolution. Caveat: interpretation of this value is tricky. Values up to 16000 will be interpreted as kilobytes (1000 bytes), anything above will be interpreted as bytes. Therefore, the maximum of 24 Mbit/s would be entered as vbitrate=24000000. (I found this results in a just marginally bigger file, so I eventually decided to stick with that.)
  • keyint=15 specifies a key frame every 15 frames. Key frames hold a full screen image, whereas all other frames hold only the changes since the last frame. Increasing this value results in a smaller file, at the cost of seek precision (video players can only seek to a key frame).

The GUI Method

Get StopMotion from the repositories. Be sure to also get mencoder – it's not a dependency but required to export a video file.

StopMotion has a rather exotic default of 12 fps – you can change that in the main window. After that, simply add your image files to your project. You can preview your movie right in StopMotion, and save it as a project you can edit again later.

When you are satisfied with the result, you can export it to a movie. Before you do that, however, I highly recommend modifying StopMotion's preferences for mencoder, as the default options produce rather blocky-looking videos at 12fps.

Change the default of:

mencoder -ovc lavc -lavcopts vcodec=msmpeg4v2:vpass=1:$opt -mf type=jpg:fps=12 -o "$VIDEOFILE" "mf://$IMAGEPATH/*.jpg"

to:

mencoder -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=16000:keyint=15:$opt -mf type=jpg:fps=25 -o "$VIDEOFILE" "mf://$IMAGEPATH/*.jpg"

After that, export your video.

Share:
8,756

Related videos on Youtube

user149408
Author by

user149408

Updated on September 18, 2022

Comments

  • user149408
    user149408 almost 2 years

    I'm making my first attempts at time-lapse photography. The images I get from my smartphone camera have the timestamp in their file name – thus they are sortable, but not consecutively numbered, foiling any attempts to run them through ffmpeg.

    How can I process these images into a time-lapse video? OS is Ubuntu MATE 16.04.