Skip to content

Instantly share code, notes, and snippets.

@knugie
Last active May 25, 2022 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knugie/db876679a75b3c5ab4608e96357a3302 to your computer and use it in GitHub Desktop.
Save knugie/db876679a75b3c5ab4608e96357a3302 to your computer and use it in GitHub Desktop.
Generate a gif from an mp4 file
# Using ffmpeg
ffmpeg -y -i video.mp4 -vf fps=1,scale=600:-1:flags=lanczos,palettegen palette.png
ffmpeg -i video.mp4 -i palette.png -filter_complex "setpts=0.125*PTS,fps=5,scale=600:-1:flags=lanczos[x];[x][1:v]paletteuse" video.gif
# OR
# Using ffmpeg and gifsicle (https://www.lcdf.org/gifsicle/)
ffmpeg -i video.mp4 -s 600x400 -r 3 -f gif - | gifsicle --delay=3 > video.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment