Skip to content

Instantly share code, notes, and snippets.

@michaelhollman
Last active December 6, 2016 01:16
Show Gist options
  • Save michaelhollman/3dabf3990aed46866f67 to your computer and use it in GitHub Desktop.
Save michaelhollman/3dabf3990aed46866f67 to your computer and use it in GitHub Desktop.
ffmpeg commands

Make a timelapse from images

ffmpeg -framerate 30 -f image2 -i images_%05d.JPG -r 30 -vcodec libx264 -pix_fmt yuv420p -crf 20 output.mp4
  • -framerate 30 input images at 30fps
  • -f image2 process the input as images
  • -i blahblahblah input
  • -r 30 output 30fps
  • -vcodec libx265 encode w/ h.264
  • -pix_fmt yuv420p adjust color space to make players happy
  • -crf 20 a slightly nicer crf (standard is 23)

Simple concat

ffmpeg -f concat -i <(printf "file '$PWD/%s'\n" ./*.MP4) -c copy concat.mp4
or…
printf "file '%s'\n" ./*.MP4 > files.txt
ffmpeg -f concat -i files.txt -c copy output

Speed-up/slow-down and adjust framerate

ffmpeg -i input.mp4 -r 60 -filter:v "setpts=0.5*PTS" output.mp4

  • -r 60 desired output framerate
  • setpts=0.5*PTS timestamp adjustment factor. value is ratio of old to new framerates. (e.g. 30 to 60 would be 0.5, 60 to 30 would be 2)

This handy tool helps generate the correct params

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