TTrimpx

Step-by-Step Guide

How to Convert Video to Animated GIF with Best Quality

Learn how to create crystal-clear animated GIFs from any video clip using FFmpeg's advanced palette generation. Includes file size optimization techniques and frame rate recommendations.

Why Custom Palettes Matter

Standard video-to-GIF conversion uses a fixed 256-color palette, which often produces muddy colors. FFmpeg's palettegen creates an optimized 256-color palette specific to your video, dramatically improving color accuracy. This technique can reduce file size by 30-50% while simultaneously improving visual quality.

Best Settings for Different Use Cases

Use CaseFrame RateWidthDither
Chat/Messaging10 fps320pxbayer
Twitter/X Posts15 fps480pxwu (Floyd-Steinberg)
High-Quality Web20 fps640pxbayer (5x)
Presentation Demo12 fps960pxwu

Step 1: Generate Custom Color Palette

Command — Generate Palette

ffmpeg -i input.mp4 \ -vf "fps=10,scale=480:-1:flags=lanczos,palettegen=stats_mode=diff" \ palette.png

Step 2: Create the GIF Using the Palette

Command — Create GIF

ffmpeg -i input.mp4 -i palette.png \ -lavfi "fps=10,scale=480:-1:flags=lanczos [x]; [x][v:1] paletteuse=dither=bayer:bayer_scale=5" \ -loop 0 output.gif

Key parameters:

  • -loop 0 — Infinite loop (remove for single-play GIF)
  • flags=lanczos — High-quality downscaling filter
  • dither=bayer:bayer_scale=5 — Ordered dithering reduces color banding
  • stats_mode=diff — Palette optimized for frame differences (smaller files)

Frequently Asked Questions

How do I make a GIF smaller in file size?

Reduce frame rate (10fps vs 15fps), reduce width (320px vs 480px), use bayer dithering instead of Wu, and add a short loop delay with -delay option. These can shrink your GIF by 40-60%.

Why not use WebP or APNG instead of GIF?

WebP animated and APNG offer much better compression than GIF while looking identical. Use them whenever possible — most modern platforms support them. GIF is only necessary for maximum compatibility.