Skip to content

Instantly share code, notes, and snippets.

@calvarez-ov
Created September 2, 2016 14:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calvarez-ov/38bb735b97f5d01757075d6f551b870c to your computer and use it in GitHub Desktop.
Save calvarez-ov/38bb735b97f5d01757075d6f551b870c to your computer and use it in GitHub Desktop.
mp4 to animated gif with brief blank screen between loops
inputfile=$1
ffmpeg -y -i $inputfile -vf fps=10,scale=320:-1:flags=lanczos,palettegen /tmp/palette.png
ffmpeg -i $inputfile -i /tmp/palette.png -filter_complex "fps=10,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" /tmp/temp.gif
convert /tmp/temp.gif -alpha Opaque +level-colors Black -flatten /tmp/black.png
convert /tmp/temp.gif -delay 50 /tmp/black.png /tmp/output.gif
@calvarez-ov
Copy link
Author

Usage: bash mp42gif.bash /path/to/video.mp4

This produces an animated gif in /tmp/output.gif

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