Sunday, March 14, 2010

Create animated gif from movie on command line

I saw a post where it was creating an sequence image from command line then using gimp to combine it, the post is at http://t.webofgoo.com/2009/02/27/create-animated-gif-from-video-in-ubuntu-linux-using-mplayer-and-gimp/comment-page-1/ and http://blog.ahfr.org/2008/03/making-animated-gifs-with-free-software.html. Now lets have more fun with it by just using command line for all the process.

You might need MPlayer and ImageMagick for this
sudo apt-get install mplayer imagemagick

The for the animated gif
mplayer -ao null -ss 0:00:01 -endpos 4 /path/to/video -vo jpeg:outdir=Extracted
cd Extracted
convert -delay 10 *.jpg -loop 0 animate.gif


If you want your full video to be converted to gif you could use this (byexamples archives)
mplayer -vo gif89a /path/to/video

For the explanation of the mplayer part please see the referenced site, for the convert please see http://www.imagemagick.org/Usage/anim_basics/.