Created
September 1, 2023 07:09
-
-
Save mgussekloo/f847cd8717ebab2935efc4c26945d3e9 to your computer and use it in GitHub Desktop.
Cat Park image processing
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 | |
#files="carmen-alternate carmen-default magnus-alternate-fullsize magnus-default-new marvin-alternate marvin-default cafe_background cybervan vendoralley apartment catpark catpark-damaged madison-default madison-thinking melonie-default melonie-angry" | |
files=('catpark_logo los') | |
palette="/tmp/palette.png" | |
filters="fps=fps=12,scale=500:-1:flags=lanczos" | |
q=40 | |
# rm -rf opti | |
# mkdir opti | |
rm -rf ../dest | |
mkdir ../dest | |
shouldresize=false | |
if [ ! -d "resized" ]; then | |
mkdir ./resized | |
echo "Resizing!" | |
sleep 2 | |
shouldresize=true | |
fi | |
for f in "${files[@]}" | |
do | |
# RESIZE RESIZE ONLT ONCE | |
if $shouldresize | |
then | |
echo "--------------------------Resizing" | |
ffmpeg -f image2 -i "${f}%03d.png" -vf "$filters" "resized/${f}%03d.png" | |
fi | |
# --- | |
ffmpeg -framerate 24 -i "${f}%03d.png" -vcodec libwebp_anim -vf "$filters" -r 24 -lossless 0 -quality ${q} -loop 0 -an -pix_fmt yuva420p "../dest/${f}.webp" | |
img2webp -loop 0 -kmax 1 -lossy -q ${q} -d 80 "resized/${f}"*.png -o "../dest/${f}_all_keyframes.webp" | |
ffmpeg -v warning -i "${f}%03d.png" -vf "palettegen=stats_mode=full" -y $palette | |
ffmpeg -i "${f}%03d.png" -i $palette -lavfi "$filters,paletteuse=dither=sierra2_4a" -y "../dest/${f}_sierra.gif" | |
gifsicle -O3 --dither=o8 --colors=128 --lossy=40 -o "../dest/${f}_sierra_reduced.gif" "../dest/${f}_sierra.gif" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment