Skip to content

Instantly share code, notes, and snippets.

@venj
Created November 1, 2016 03:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save venj/ab1c51a660eb3d9287a593808a2c40c0 to your computer and use it in GitHub Desktop.
Save venj/ab1c51a660eb3d9287a593808a2c40c0 to your computer and use it in GitHub Desktop.
convert video to gif
#!/bin/sh
# Convert video to gif.
if [[ $# -ne 3 ]]; then
echo "Usage: trans_gif source.mp4 target.gif 300"
exit 1
fi
palette="/tmp/palette.png"
filters="fps=15,scale=$3:-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