Skip to content

Instantly share code, notes, and snippets.

@vayn
Forked from venj/trans_gif.sh
Created November 1, 2016 04:05
Show Gist options
  • Save vayn/2ef2589944907e3ef8852644238e8d28 to your computer and use it in GitHub Desktop.
Save vayn/2ef2589944907e3ef8852644238e8d28 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