OS X Screencast to animated GIF
I was disappointed with the color and quality that ffmpeg's GIF conversion gives. Imagemagick's convert can also be used to do the conversion, though this has serious performance penalties.
The following details my experiments of converting a 3.8 second movie to a GIF.
ffmpeg -i in-trimmed.mov -r 10 -vcodec png out-static-%02d.png
time for img in out-static*.png; do convert -verbose +dither -layers Optimize "$img" "$img.gif" ; done
ffmpeg -i in-trimmed.mov -r 10 -vcodec png out-static-%02d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- > out13.gif
ffmpeg -i in-trimmed.mov -r 10 -vcodec png out-static-%02d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > out12.gif
ffmpeg -i in-trimmed.mov -r 10 -vcodec ppm out-static-%02d.ppm
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.ppm GIF:- > out14.gif
time ffmpeg -i in-trimmed.mov -r 10 -f image2pipe -vcodec ppm - | time convert -verbose +dither -layers Optimize -resize 600x600\> - gif:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile -> out15.gif
ffmpeg -i in-trimmed.mov -vf "scale=min(iw\,600):-1" -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=7 --colors 128 > out16.gif
This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.
To capture the video (filesize: 19MB), using the free "QuickTime Player" application:
in.mov
To convert in.mov into out.gif (filesize: 48KB), open Terminal to the folder with in.mov
and run the following command:
ffmpeg -i in.mov -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > out.gif
Notes on the arguments:
-r 10
tells ffmpeg to reduce the frame rate from 25 fps to 10-s 600x400
tells ffmpeg the max-width and max-height--delay=3
tells gifsicle to delay 30ms between each gif--optimize=3
requests that gifsicle use the slowest/most file-size optimizationTo share the new GIF using Dropbox and Copy Public URL, run the following:
cp out.gif ~/Dropbox/Public/screenshots/Screencast-`date +"%Y.%m.%d-%H.%M"`.gif
The conversion process requires the following command-line tools:
If you use homebrew and homebrew-cask software packages, just type this in:
brew install ffmpeg
brew cask install x-quartz #dependency for gifsicle, only required for mountain-lion and above
open /usr/local/Cellar/x-quartz/2.7.4/XQuartz.pkg # runs the XQuartz installer
brew install gifsicle
I ended up rewriting this gist's functionality into screengif, a ruby script with significant quality improvements and a few gratuitous features. Check it out at https://github.com/dergachev/screengif