Skip to content

Instantly share code, notes, and snippets.

@cassiozen
Created May 22, 2025 19:06
Show Gist options
  • Save cassiozen/0470a5cf0e56ab676de46f8e64242dc4 to your computer and use it in GitHub Desktop.
Save cassiozen/0470a5cf0e56ab676de46f8e64242dc4 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Creates an animated gif from video using an explicit color pallete with space handling
# usage: mov2gif input.mov [output.gif]
in="$1"
out="${2:-${in%.*}.gif}"
# tweak fps / scale here
fps=12
width=600
ffmpeg -loglevel error -hide_banner -i "$in" \
-filter_complex "
colorspace=all=bt709:iall=bt709:fast=0,format=rgb24,
fps=${fps},scale=${width}:-1:flags=lanczos,
split [main][pal];
[pal] palettegen=stats_mode=full [p];
[main][p] paletteuse=dither=sierra2_4a
" \
-y "$out"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment