Skip to content

Instantly share code, notes, and snippets.

@artursapek
Last active August 29, 2015 14:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save artursapek/11453978 to your computer and use it in GitHub Desktop.
Convert .mov files to GIFs easily
brew install ffmpeg
brew install imagemagick
brew install libtool --universal
brew link libtool
#!/bin/bash
# Usage:
# mov2gif input output dimensions(optional)
# mov2gif screen-capture.mov screen-capture.gif 400
tmp_dir=/tmp/frames_$(date +%s)
mkdir $tmp_dir
if [ -z "$3" ]
then
size=600
else
size=$3
fi
echo "Converting $1 => $2 ($3 px wide)"
echo "Generating frames"
(ffmpeg -i $1 -vf scale=$size:-1 -r 10 $tmp_dir/ffout%03d.png) >& /dev/null
echo "Building gif from frames"
(convert -delay 5 -loop 0 $tmp_dir/ffout*.png $2) >& /dev/null
echo "Cleaning up"
rm -rf $tmp_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment