Picture of Bird

Making Time Lapse Videos From JPGs

Introduction

I recently wanted to combine a series of JPGs into time lapse video, however I soon discovered that Adobe Lightroom CC doesn't have the native ability to do this and the Lightroom presets and plugins that some people have used in the past are in a format no longer supported by the latest version. So I went searching for another tool...

Enter FFmpeg

FFmpeg is a set of highly-capable video processing libraries and tools available for free on Windows, Mac and Linux. I had used FFmpeg occasionally in the past for various one-off video operations and was delighted to find that it could also be used to convert time lapse image files into a video. After some heavy googling and some trial and error I came up with a command line usage that worked for me:

ffmpeg \
     -r 24 \
     -pattern_type glob_sequence \
     -start_number 131 \
     -i "DSC%05d.JPG" \
     -s hd1080 \
     -vcodec libx264 \
     -pix_fmt yuv420p \
     -preset veryslow \
     timelapse-output.mp4

The options used are as follows:

  • -r 24

    Frame rate, in this case 24 frames/sec. You can play around with this number to get the right speed and smoothness of your time lapse video, keep in mind the timing interval you used when taking the pictures will have impact on the frame rate you can specify here that will look good.

  • -pattern_type glob_sequence

    -pattern_type glob_sequence tells ffmpeg that filename pattern will be used in the -i parameter. Note: glob_sequence is the default pattern type, but there are many examples on the web using the different glob type I felt it important to specify it explicitly here.

  • -i "DSC%05d.JPG"

    -i "DSC%05d.JPG" is the input filename pattern. In my case the filenames I have are in the form of 'DSC00279.JPG'. The "DSC%05d.JPG" pattern indicates: 'DSC' followed by a 5 digit (zero-padded) sequence number and then finally the '.JPG' extension, you'll need to customize this pattern to match your particular files.

  • -start_number 131

    FFmpeg does a sanity check when looking for image files to combine. It first looks for a filename at an initial 'start number' (defaults to 0) and looks for at least one file within the 'start number range' (defaults to 5). If it doesn't find a file within that range you'll get the following error:

    Could find no file with path 'DSC%05d.JPG' and index in the range 0-4
    DSC%05d.JPG: No such file or directory

    -start_number is used to tell ffmpeg where to start looking for files, in my case my first file was 'DSC00131.JPG' so -start_number 131 tells ffmpeg to start there.

  • -s hd1080

    Sets the frame size to hd1080 (ie 1920x1080), there is a list of alternative sizes here.

  • -vcodec libx264

    Sets the output video codec to use as libx264.

  • -pix_fmt yuv420p

    Changes the pixel format to yuv420p. This is used to increase compatibility with players including Quicktime.

  • -preset veryslow

    I add this option to minimize the output file size. There is a note on the FFmpeg wiki for H.264 to 'Use the slowest preset that you have patience for", and I'm pretty patient : ). If not specified it defaults to 'medium'

  • timelapse-output.mp4

    And finally the output filename. Note that ffmpeg can output different video formats and will use the output filename extension (ie .mp4) to determine the format to write.

Final Thoughts

The above example barely scratches the surface of what ffmpeg is capable of, particularly with regard the video options. If you plan on getting deeper into video manipulation then ffmpeg is a great (and sometimes the only) tool for the job.