Create an Animated GIF from Video with ffmpeg

Build a small, good-looking GIF on macOS with ffmpeg's palettegen/paletteuse filter chain (ffmpeg is not preinstalled).

macOSvideoffmpeggifLow risk
Install ffmpeg, then run the palettegen/paletteuse one-liner with fps=12 and scale to trim, downscale, and encode the GIF.

01Command

Command
$ ffmpeg -ss 3 -t 4 -i input.mp4 -vf "fps=12,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" out.gif

02What it does

A naive `ffmpeg -i in.mp4 out.gif` produces huge, dithered GIFs; generating a 256-color palette first and applying it with paletteuse gives dramatically better quality at smaller size. -ss 3 -t 4 trims a 4-second clip starting at 3 seconds, and fps=12,scale=480:-1 keeps the file shareable. ffmpeg is not included with macOS — install it with `brew install ffmpeg`.

03Risk

RiskLow risk
Requirementsffmpeg (brew install ffmpeg)
!Warning: GIF files grow fast: keep clips short and resolution low, or convert to MP4/WebM instead.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • ffmpeg — Homebrew formula
    Homebrew · community · 2026-09-17
    Evidence: ffmpeg is not preinstalled on macOS; install via `brew install ffmpeg`.
  • Create GIF — FFmpeg wiki
    FFmpeg · vendor-doc · 2026-09-17
    Evidence: Shows the palettegen/paletteuse two-pass filter chain for high-quality GIFs, with fps and scale filters.

Last verified: 2026-09-17 · Category: Media