Tuesday, October 19, 2010

Animated Gifs with Linux, Gimp, mPlayer

I have learned to create animated GIFs from YouTube clips in Linux and this is how I did it.

With FireFox I went to the desired video on YouTube and played the video I wanted.

Looked for the latest file created in /tmp
 
ls -lrt /tmp/Flash*
/tmp/FlashXXzPQB05

Copied the latest Flash* file created to my homedir

cp /tmp/FlashXXzPQB05 /my/home/dir/SomeFile.flv

I used the following command several times, each time adjusting the start time and stop time until I got the section of the video I wanted

mplayer -ao null -loop 0 -ss 00:00:03 -endpos 8 SomeFile.flv

When I got the section of video I wanted, I then converted the video to a series of JPEGs that got dumped to the AnimGifs directory

mplayer -ao null -ss 00:00:03 -endpos 8 FreshPrince.flv -vo jpeg:outdir=AnimGifs

  1. Open the first image with GIMP (I'm using 2.6) 
  2. Open the rest of the images by going to File->Open as Layers and selecting all the desired images (except the first one) 
  3. Save the image as SomeFile.gif and choose the save as animation option and click export 

If the image is too fast .. run the whole procedure again but save the GIF with 45 to 40 MilliSecond delay.