Last active
November 25, 2016 03:46
-
-
Save kana-ph/9e72cbd4c917e77309a601c04182a00c to your computer and use it in GitHub Desktop.
Convert OGV to GIF using ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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