Skip to content

Instantly share code, notes, and snippets.

@ProGM
Last active June 7, 2016 08:41
Show Gist options
  • Save ProGM/d687b1bb5b7726c567e98f1cee544c6f to your computer and use it in GitHub Desktop.
Save ProGM/d687b1bb5b7726c567e98f1cee544c6f to your computer and use it in GitHub Desktop.
A script to create a gif from a video!
#!/usr/bin/env bash
#
# Usage:
# $ video2gif.sh in.avi out.gif [width]
#
# Based on http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
size=$3
if [ -z $size ]; then
size=320
fi
rm "/tmp/palette.png" > /dev/null
palette="/tmp/palette.png"
filters="fps=10,scale=$size:-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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment