FFmpeg recipe

FFmpeg: Convert MP4 to GIF with Custom Palette

Default ffmpeg GIF uses the web palette and looks posterized. Custom palette extraction picks the optimal 256 colors for your specific clip.

Command

ffmpeg -i input.mp4 -vf "fps=15,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -y output.gif
Prefer no terminal?
Use the Video to GIF in your browser
Open Video to GIF

What each flag does

-iInput file. Can be a video, audio, or image. Repeat for multiple inputs.
-yOverwrite output file without confirmation.
-vf "..."Filter chain: set FPS, resize, then split → palettegen → paletteuse for optimal color quality.
fps=1515 fps is the GIF sweet spot — smooth enough, file size half of 30 fps.
scale=480:-1Resize to 480 px wide, height auto. Smaller width = much smaller GIF.
palettegenBuild a custom 256-color palette tuned to this clip.

Notes & gotchas

  • Drop FPS to 12 or width to 360 for stricter file size budgets.
  • Add dither=bayer:bayer_scale=5 to paletteuse for smoother gradients (slightly larger file).

Related recipes