Created
August 15, 2022 14:38
-
-
Save Utopiah/ad39e20ce7004353970bc6a1d163e248 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
twitterGif(){ | |
ffmpeg -hide_banner -i "$1" -filter_complex "[0:v] fps=12,$2split [a][b];[a] palettegen [p];[b][p] paletteuse" -y ~/ok.gif | |
# optional 2nd parameter for scale, e.g twitterGif largevideo.mp4 scale=600:-2, | |
} | |
twitterGifConvergeSize(){ | |
SCALE=1 | |
twitterGif $1 # try without changing the scale | |
while [ $(find ok.gif -size +10M -size -15M | wc -l) -lt 1 ]; do | |
if [ $(find ok.gif -size -15M | wc -l) -lt 1 ]; then | |
SCALE=$(echo $SCALE / 2 | bc -l) | |
elif [ $(find ok.gif -size +10M | wc -l) -lt 1 ]; then | |
SCALE=$(echo $SCALE \* 1.5 | bc -l) | |
fi | |
twitterGif $1 scale=iw*$SCALE:-2, | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment