Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 29 lines (19 sloc) 701 Bytes
#!/usr/bin/env bash
# ffnicegif: Generate a more compact GIF from an input file
# stolen from http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
set -eo pipefail
function help {
echo "Usage: ffnicegif <input> <output>"
exit
}
function installed {
cmd=$(command -v "${1}")
[[ -n "${cmd}" ]] && [[ -f "${cmd}" ]]
return ${?}
}
[[ $# -eq 2 && -f $1 && ! -f $2 ]] || help
installed ffmpeg || { >&2 echo "Missing ffmpeg."; exit 1; }
palette="/tmp/palette.png"
filters="fps=15,scale=-1:-1:flags=lanczos"
ffmpeg -v warning -i "${1}" -vf "${filters},palettegen" -y "${palette}"
ffmpeg -v warning -i "${1}" -i "${palette}" -lavfi "${filters} [x]; [x][1:v] paletteuse" -y "${2}"