28 December 2009 4 Comments

How to Convert a YouTube Video to an Animated GIF

youtube

Sometimes you may need to make a GIF file from a video for using it as an avatar or different purposes. Today i will show you two ways to make a GIF from a Youtube video :
1 – Using mplayer
2 – Using Avidemux + ffmpeg + Gimp (More detailed = More customizable)
I do use youtube-dl ($sudo apt-get install youtube-dl) to download videos from Youtube, however you can use other ways like copying the flv from /tmp folder, an online converter, different softwares etc.


Using Mplayer

This is the easiest way to convert a video to a GIF. Just download the video with youtube-dl then give this command :

$mplayer -vo gif89a yourvideosfilename.flv

The GIF file (out.gif) will be inside the directory after playing the video.

Using Avidemux + ffmpeg + Gimp

As you can see from the title, you need to install avidemux, ffmpeg and gimp (all at the repositories) to use this method. This is a little more detailed way than the first one but in this way you can rip the video file before converting to a GIF. After downloading your video file, convert your FLV file to avi. That is the purpose of ffmpeg here :

$ffmpeg -i youtubefilename.flv filename.avi

Now launch avidemux, open the avi file we have created a couple of minutes ago. Select the range you want to rip using A and B buttons at the buttom. After you are done, save the images to a new directory via navigating to File->Save->Save Selection As Jpeg Images.

Tips: You can use Phatch to reduce size, change resolution and other things on Jpeg file before making it a GIF.

Open Gimp and open the first part of the Jpeg series. Then go to File->Open As Layers and select the rest of the series. After that go to Filters->Animation->Optimize For Gif . Now save it as GIF and you are done.

  • http://www.easydvdburning.com/ DVD Burning

    Nice share! I will definitely try this and see if it works.

  • vetboo

    A computer can do lots of things.

  • http://www.domain-hosting-services.in/ Domain hosting

    Thanks for sharing this and i will definitely try this. Hop it will work for me.

  • ecoamteo

    Thanks for your sharing!