Jon Skinner implemented a similar technique to create and display screencast animations on the Sublime Text homepage. I was just reading his article[1] last night in which he discussed his technique.
It's similar to this implementation, and his source is available on Github[2] (written in Python).
It's similar to this implementation, and his source is available on Github[2] (written in Python).
[1] http://www.sublimetext.com/~jps/animated_gifs_the_hard_way.h...
[2] http://github.com/sublimehq/anim_encoder