Skip to main content

High quality GIF with FFmpeg shell script.

#!/usr/bin/env bash

##
# High quality GIF with FFmpeg
# http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
#
# Usage:
#   ./gifenc.sh in.mov out.gif
##

palette="palette.png"
filters="fps=10,scale=1024:-1:flags=lanczos"

ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2