Skip to content

Instantly share code, notes, and snippets.

@Klemek
Created July 3, 2019 12:41
Show Gist options
  • Save Klemek/a07106870d3acd484beb02238a84c176 to your computer and use it in GitHub Desktop.
Save Klemek/a07106870d3acd484beb02238a84c176 to your computer and use it in GitHub Desktop.
#!/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