Skip to content

Instantly share code, notes, and snippets.

@kana-ph
Last active November 25, 2016 03:46
Show Gist options
  • Save kana-ph/9e72cbd4c917e77309a601c04182a00c to your computer and use it in GitHub Desktop.
Save kana-ph/9e72cbd4c917e77309a601c04182a00c to your computer and use it in GitHub Desktop.
Convert OGV to GIF using ffmpeg
#!/bin/sh
# Sources: http://unix.stackexchange.com/questions/35282/convert-ogv-video-to-gif-animation
# http://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality/556031#556031
if [ "$#" -gt 0 ]; then
input=$1
output=${input/.ogv/-ogv.gif}
if [ -f $output ]; then
rm $output
fi
temp_palette=/tmp/ogv2gif-palette.png
filters="fps=15,scale=-1:-1:flags=lanczos"
ffmpeg -v quiet -i $input -vf "$filters,palettegen" $temp_palette
ffmpeg -v quiet -i $input -i $temp_palette -loop 0 -filter_complex "$filters[x]; [x][1:v] paletteuse" $output
rm $temp_palette
exit 0
else
echo "FATAL: Missing input"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment