Skip to content

Instantly share code, notes, and snippets.

@alexellis
Forked from porjo/timelapse.md
Created March 9, 2017 08:48
Show Gist options
  • Save alexellis/bbf2bc2a6789480fcd0031f99800df9c to your computer and use it in GitHub Desktop.
Save alexellis/bbf2bc2a6789480fcd0031f99800df9c to your computer and use it in GitHub Desktop.
ffmpeg time-lapse

Convert sequence of JPEG images to MP4 video

ffmpeg -r 24 -pattern_type glob -i '*.JPG' -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse.mp4

  • -r 24 - output frame rate
  • -pattern_type glob -i '*.JPG' - all JPG files in the current directory
  • -i DSC_%04d.JPG - e.g. DSC_0397.JPG
  • -s hd1080 - 1920x1080 resolution

Slower, better quality

Add the following after -vcodec libx264 to achieve better quality output

-crf 18 -preset slow

Bulk convert JPGs to 1920x1080, centered

convert input.jpg -resize '1920x1080^' -gravity center -crop '1920x1080+0+0' output.jpg

@sxiii
Copy link

sxiii commented Jun 12, 2020

@jtanman -- I think it would be much easier to write a bash script that does the following:

  • creates temp directory
  • copies all files from DIR1 to temp
  • copies all files from DIR2 to temp
  • runs FFMPEG with your files in temp directory and creates result movie
  • moves your movie from temp to current directory
  • removes the temp directory
    :) This should work fast & easy.

@putout
Copy link

putout commented Jan 14, 2021

hi the command provided above in the original post only creates about 10 seconds duration in the video i have 1000+ images in the directory. ..

ffmpeg -r 24 -pattern_type glob -i '*.jpg' -s hd1080 -vcodec libx264 timelapse.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment