Skip to content

Instantly share code, notes, and snippets.

@ansballard
Created March 7, 2017 05:09
Show Gist options
  • Save ansballard/f7bcbbfa11f43597f3e8731d9961d56c to your computer and use it in GitHub Desktop.
Save ansballard/f7bcbbfa11f43597f3e8731d9961d56c to your computer and use it in GitHub Desktop.
Convert a video file to a gif with ffmpeg
FILENAME=${1:-"screencast"}
FPS=${2:-"30"}
WIDTH=${3:-"1366"}
PALETTE="/tmp/palette.png"
FILTERS="fps=$FPS,scale=$WIDTH:-1:flags=lanczos"
ffmpeg -v warning -i $FILENAME -vf "$FILTERS,palettegen" -y $PALETTE
ffmpeg -v warning -i $FILENAME -i $PALETTE -lavfi "$FILTERS [x]; [x][1:v] paletteuse" -y $FILENAME.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment