Extremely high-quality MP4 to GIF with ffmpeg command

To create an extremely high-quality GIF from an MP4 with ffmpeg, you should render a high-quality palette from the source, then use that palette to dither/quantize the frames. Also consider resizing and frame-rate control to keep file size reasonable.

Two-step method (recommended):

  1. Generate a high-quality palette ffmpeg -y -i input.mp4 -vf "fps=15,scale=iw:-1:flags=lanczos,palettegen=max_colors=256:stats_mode=full" -qscale:v 1 palette.png

  2. Use the palette to create the GIF ffmpeg -i input.mp4 -i palette.png -lavfi "fps=15,scale=iw:-1:flags=lanczos[x];[x][1:v]paletteuse=dither=sierra2_4a" -loop 0 output.gif

Notes and options:

  • fps=15: adjust to taste (common values 10–24). Lowering fps reduces size. Use the original frame rate or a multiple if you want very smooth motion.
  • scale=iw:-1 keeps original width, adjusts height to preserve aspect ratio. For large sources you may want scale=800:-1 (or another width) to limit GIF dimensions.
  • flags=lanczos uses a high-quality scaler.
  • palettegen=max_colors=256:stats_mode=full produces a high-quality palette (256 colors is maximum for GIF). You can reduce to 128/64 to reduce size/artifacts.
  • paletteuse dither options: dither=sierra2_4a gives good visual quality; try dither=bayer or dither=none for different artifacts. You can also use paletteuse=new=1 for improved results with some builds.
  • -qscale:v 1 on palette generation ensures best internal quality when creating the palette.
  • -loop 0 makes the GIF loop forever. Use -loop 1 for single play in some players.

Single-line example (replace fps/scale as needed): ffmpeg -y -i input.mp4 -vf "fps=15,scale=800:-1:flags=lanczos,palettegen=max_colors=256:stats_mode=full" palette.png && ffmpeg -i input.mp4 -i palette.png -lavfi "fps=15,scale=800:-1:flags=lanczos[x];[x][1:v]paletteuse=dither=sierra2_4a" -loop 0 output.gif

If file size is a concern, consider:

  • Reducing fps and/or resolution
  • Lowering max_colors in palettegen
  • Converting to a short WebP animation instead of GIF for better quality/size (ffmpeg can produce animated WebP with -vcodec libwebp)

If you want, tell me the input resolution, duration and target file-size or target width/fps and I can give a tailored command.

Have your own question?

Ask the AI now

Free · no account needed · answer in seconds