星期六, 5月 01, 2010

FLV to GIF

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.

1- 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.

2- 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.

###Optional###
You can use Phatch to reduce size, change resolution and other things on Jpeg file before making it a GIF.
###End of Optional Part###

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.

FROM: here

沒有留言: