Created
May 5, 2023 14:20
-
-
Save aantix/c1e90a81c5c6f2acf6a506f0d4fb7f17 to your computer and use it in GitHub Desktop.
Convert mp4 video to optimized gif
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/bash | |
# https://www.bannerbear.com/blog/how-to-make-a-gif-from-a-video-using-ffmpeg/ | |
# Mac OSX | |
# brew install ffmpeg | |
# brew install gifsicle | |
echo "Extracting the palette." | |
ffmpeg -i $1 -filter_complex "[0:v] palettegen" palette.png | |
echo "Converting from mp4 to gif." | |
ffmpeg -i $1 -i palette.png -filter_complex "[0:v] fps=10,scale=320:-1 [new];[new][1:v] paletteuse" $1.gif | |
echo "Optimizing gif." | |
gifsicle -O3 --lossy=100 $1.gif -o $1.optimized.gif | |
echo "Generated." | |
echo $1.optimized.gif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment