Skip to content

Instantly share code, notes, and snippets.

@discatte
Last active June 27, 2022 17:03
Show Gist options
  • Save discatte/3de08bfe6b3d8c26c08890c2325089ae to your computer and use it in GitHub Desktop.
Save discatte/3de08bfe6b3d8c26c08890c2325089ae to your computer and use it in GitHub Desktop.
ffmpeg optimized animated gif
# Gif optimization based on
# https://cassidy.codes/blog/2017/04/25/ffmpeg-frames-to-gif-optimization/
# http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
# https://github.com/intgr/keep-on-giffing
ffmpeg -i "my_frames_%03d.png" \
-vf "palettegen=stats_mode=diff:max_colors=256" \
"my_palette.png"
ffmpeg -i "my_frames_%03d.png" \
-i "my_palette.png" \
-lavfi "paletteuse=dither=bayer:diff_mode=rectangle" \
"my_animation.gif"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment