Skip to content

Instantly share code, notes, and snippets.

@rwrrll
Last active August 29, 2015 14:15
Show Gist options
  • Save rwrrll/295cc72a9cb5bc184077 to your computer and use it in GitHub Desktop.
Save rwrrll/295cc72a9cb5bc184077 to your computer and use it in GitHub Desktop.
Convert QuickTime screen recordings to lightweight animated GIFs.
#! /bin/bash
# you need ffmpeg and gifsicle installed. they're available via brew on a mac.
# sips will already be installed on your mac.
# you probably want an existence check here, but I'm lazy.
rm out.gif
mkdir pngs
# you can change 450 to your desired output width. the aspect ratio will be preserved.
# the -r switch here effectively controls the framerate: lower frame rate = smaller file size.
ffmpeg -i input.mov -vf scale=450:-1 -r 4 pngs/out%04d.png
mkdir gifs
sips -s format gif pngs/*.png --out ./gifs &> /dev/null
cd gifs
# the delay parameter here controls how long the last frame will hang around before looping.
# changing the colors parameter will trade off image quality for file size.
gifsicle *.gif --optimize=3 --delay=3 --colors 72 --loopcount > ../out.gif
cd ../
rm -r pngs
rm -r gifs
echo Finished!
du -h out.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment