Created
July 3, 2019 12:41
-
-
Save Klemek/a07106870d3acd484beb02238a84c176 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
set -e | |
if [[ -z "$1" ]]; then | |
echo "please enter file" | |
exit 1 | |
fi | |
filename=$(basename -- "$1") | |
filename="${filename%.*}" | |
echo "filename:$filename" | |
read -p 'Scale (480): ' scale | |
if [[ -z $scale ]]; then | |
scale=480 | |
fi | |
read -p 'FPS (20):' fps | |
if [[ -z $fps ]]; then | |
fps=20 | |
fi | |
ffmpeg -y -i "$1" -vf fps=$fps,scale=$scale:-1:flags=lanczos,palettegen palette.png | |
ffmpeg -y -i "$1" -i palette.png -filter_complex "fps=$fps,scale=$scale:-1:flags=lanczos[x];[x][1:v]paletteuse" temp.gif | |
gifsicle -O3 temp.gif -o "$filename.gif" | |
rm -f palette.png | |
rm -f temp.gif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment