Tutorial

Create a GIF from Video with FFmpeg

Use this guide to generate a good-looking GIF from a video clip by creating a palette first and then rendering the final GIF.

Install FFmpeg (if not already installed):

Generate palette for better GIF quality

First create a palette:

ffmpeg -ss 00:00:10 -t 3 -i input.mp4 -vf "fps=12,scale=640:-1:flags=lanczos,palettegen" palette.png
  • -ss
    is the start time.
  • -t
    is the clip duration.
  • fps=12
    helps reduce file size.
  • scale=640:-1
    scales to 640px width.

Create GIF with the palette

Then render the GIF:

ffmpeg -ss 00:00:10 -t 3 -i input.mp4 -i palette.png -lavfi "fps=12,scale=640:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif

Replace time values and file names as needed.

Tip: Higher FPS and resolution improve quality but increase file size significantly.