Last active
January 13, 2022 11:37
-
-
Save marciopuga/51a14e048958abc581665e4e22655776 to your computer and use it in GitHub Desktop.
video to gif using ffmpeg with superior quality
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 | |
# run docker version instead of local installation | |
alias ffmpeg='docker run -v=`pwd`:/tmp/ffmpeg opencoconut/ffmpeg' | |
palette="palette.png" | |
# adjust fps here if you need to | |
filters="fps=10,scale=$1:-1:flags=lanczos" | |
# create a palette with the colors beforehand for superior results | |
ffmpeg -v warning -i $2 -vf "$filters,palettegen" -y $palette | |
# convert video to gif using the palette | |
ffmpeg -v warning -i $2 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $3 | |
# remove the palette | |
rm palette.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
./gif.sh 480 example.mov example.gif