Skip to content

Instantly share code, notes, and snippets.

@andrew-stclair
Created September 12, 2025 06:59
Show Gist options
  • Select an option

  • Save andrew-stclair/9e04de25b47b3cc985100297ec588aec to your computer and use it in GitHub Desktop.

Select an option

Save andrew-stclair/9e04de25b47b3cc985100297ec588aec to your computer and use it in GitHub Desktop.
Convert Sequentially named images into a video

Converting sequentially named images into a video

Step 1: Rename the files in sequence

rename 'our $i; s/_.*/sprintf("_%03d.png", $i++)/e' *.png

This command assumes the file name followes something like image_001.png or IMG_001.png etc...

It will then change the numbers at the end to start from 001 to however many images there are without skipping a number

(Be sure to update the %03d in the middle for however many images you have, the 3 represents how many digits are in the number)

Step 2: Convert to video

ffmpeg -framerate 30/1 -i IMG_%03d.png -c:v libx265 -vf "fps=30,format=yuv420p" timelapse.mp4

the format of -framerate is frames/second, for example 30 frames a second is 30/1, or one frame every three seconds is 1/3

-i is the input file, or in this case the images, change this to suit the image naming convention you are using, the %03d should match the previous command

-c:v libx265 is the video encoding to use, libx264 is more common

-vf "fps=30,format=yuv420p" is how the output video will be encoded, this example will be 30 frames a second using the yuv420p format, which is commonly supported

timelapse.mp4 is the output file, change it to .gif if you want an animated gif

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