Create Time-lapse from Image Sequence with FFmpeg

Creating a time-lapse video from a series of sequentially numbered images is a highly efficient process when using FFmpeg, a powerful command-line tool. This guide provides a straightforward, step-by-step tutorial on how to compile your sequential image files into a high-quality video, explaining the essential command-line arguments, frame rate adjustments, and output configurations needed to get the best results.

The Basic Command

To build a time-lapse video, open your terminal or command prompt, navigate to the folder containing your images, and run the following command:

ffmpeg -framerate 24 -i image_%04d.jpg -c:v libx264 -pix_fmt yuv420p output.mp4

Command Breakdown

Advanced Adjustments

Adjusting Video Quality

By default, FFmpeg will choose a standard quality. If you want to control the quality and file size, use the Constant Rate Factor (-crf) flag. Values range from 0 to 51, where lower means better quality (18–23 is recommended for a great balance):

ffmpeg -framerate 30 -i image_%04d.jpg -c:v libx264 -crf 18 -pix_fmt yuv420p output.mp4

Scaling the Output Video

High-resolution camera images can make the video file unnecessarily large. You can scale down the images (for example, to 1080p) during the rendering process using the scale filter:

ffmpeg -framerate 24 -i image_%04d.jpg -vf "scale=1920:-2" -c:v libx264 -pix_fmt yuv420p output.mp4

(Note: -2 tells FFmpeg to automatically calculate the height relative to the width to maintain the original aspect ratio, ensuring the dimension is divisible by 2, which is required by the H.264 codec).