Skip to content

Instantly share code, notes, and snippets.

@kana
Created December 19, 2017 09:41
Show Gist options
  • Save kana/5ddb90bdccb6e7944147af32179613a0 to your computer and use it in GitHub Desktop.
Save kana/5ddb90bdccb6e7944147af32179613a0 to your computer and use it in GitHub Desktop.
#!/bin/bash
colors=256
fps=30
half=
while true
do
case "$1" in
'-c')
colors="$2"
shift 2
;;
'-f')
fps="$2"
shift 2
;;
'-2')
half=t
shift 1
;;
*)
break
;;
esac
done
ffmpeg -y -i "$1" -vf "palettegen=max_colors=$colors:reserve_transparent=1:stats_mode=full" "${1/.*/.png}"
if [ "$half" = '' ]
then
ffmpeg -y -i "$1" -i "${1/.*/.png}" -filter_complex 'paletteuse=dither=none:bayer_scale=0' -r "$fps" "${1/.*/.gif}"
else
ffmpeg -y -i "$1" -i "${1/.*/.png}" -filter_complex '[0:v]scale=iw*.5:ih*.5,paletteuse=dither=none:bayer_scale=0' -r "$fps" "${1/.*/.gif}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment