Created
September 22, 2016 15:26
-
-
Save cyphunk/f4b1d63f596b7678efd3897c54cd6179 to your computer and use it in GitHub Desktop.
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 -x | |
# Based on http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html | |
echo "for options see" | |
echo "http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html" | |
if [ $# -ne 4 ]; then | |
echo "$0 <file> <name> <start_00:00:00> DURATION" | |
exit | |
fi | |
FILE="$1" | |
NAME="$2" | |
START="$3" | |
END="$4" | |
palette="/tmp/palette.png" | |
GenOptFavorMovement="=stats_mode=diff" | |
UseOptNoDither="=dither=none" | |
#filters="fps=15,scale=320:-1:flags=lanczos" | |
#filters="fps=10" | |
#filters="fps=10,scale=320:-1:flags=lanczos" | |
filters="fps=10,scale=640:-1:flags=lanczos" | |
filters="fps=6,scale=320:-1:flags=lanczos" | |
filters="fps=6,scale=640:-1:flags=lanczos" | |
#fast="setpts=0.38*PTS," | |
#NOGOOD: filters="fps=10,scale=160:-1:flags=lanczos,$optnodither" | |
#ffmpeg -v warning \ | |
# -i ${FILE} -ss $START -t $END -vf "$filters,palettegen" -y $palette | |
ffmpeg -ss $START -t $END -i ${FILE} -vf "$filters,palettegen$GenOptFavorMovement" -y $palette | |
ffmpeg -ss $START -t $END -i ${FILE} -i $palette -lavfi "$fast$filters [x]; [x][1:v] paletteuse$UseOptNoDither" -y ${NAME}.gif | |
#ffmpeg -i ${FILE} -ss $START -t $END -r 10 -vf scale=600:-1 ${NAME}.gif | |
## | |
echo try | |
echo gifsicle -O3 --lossy=80 $NAME.gif --output ${NAME}_compressed80.gif | |
echo gifsicle -O3 --lossy=140 $NAME.gif --output ${NAME}_compressed140.gif | |
echo gifsicle -O3 --lossy=200 $NAME.gif --output ${NAME}_compressed20.gif | |
echo lossy flag requires https://kornel.ski/lossygif extension |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment