Skip to content

Instantly share code, notes, and snippets.

@CharStiles
Last active April 24, 2018 19:59
Show Gist options
  • Save CharStiles/52d2ae99147b481f47eedca9a2911e73 to your computer and use it in GitHub Desktop.
Save CharStiles/52d2ae99147b481f47eedca9a2911e73 to your computer and use it in GitHub Desktop.
# my fork of https://gist.github.com/SlexAxton/4989674
gifify() {
if [[ -n "$1" ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
if [[ $2 == '--small' ]]; then
a=$(ls out-static* | wc -l)
for p in $(ls -r out-static*);
do
out=$(printf "out-static-%05d.png" $a)
let "a++"
cp $p $out
done
time convert -verbose +dither -layers OptimizePlus -resize 25% \> out-static*.png GIF:- | gifsicle --colors 256 --delay=5 --loop --optimize=3 --multifile - > $1.gif
# OptimizePlus
else
a=$(ls out-static* | wc -l)
for p in $(ls -r out-static*);
do
out=$(printf "out-static-%05d.png" $a)
let "a++"
cp $p $out
done
time convert -verbose +dither -layers OptimizePlus -resize 600x600\> out-static*.png GIF:- | gifsicle -- colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
# time convert -coalesce +dither -duplicate 1,-2-1 -loop 0 -treedepth 5 -colors 128\> out-static*.png $1.gif
fi
rm out-static*.png
else
echo "proper usage: gifify <input_movie.mov>. You DO need to include extension."
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment