NOTE: you will need these installed: Imagemagick, Mplayer, Mencoder (which may be part of Mplayer) and any dependancies for them. Use "sudo apt-get install" to get them.

- If you are converting only an AVI, skip to step 10. If you wish to convert Youtube videos, continue.
- Navigate to your home directory (any will do, but for simplicity everything will be done here).
- Create a document called "youtube.sh", omitting the quotation marks.
- Open the file using whichever editor you want and add this code:
- Code: Select all
wget -q -O - http://www.youtube.com/watch?v=$1|grep "/watch_fullscreen?.*video_id=.*\&t="|sed "s/^.*\&t=//"|sed "s/\&.*//"|xargs -i wget -O $2 http://youtube.com/get_video?video_id=$1\&t={}\&fmt=22
- Open a terminal.
- Run "chmod +x youtube.sh" to allow you to run the file as a script (again, omit the quotation marks).
- Find the video ID that you want to download by taking the unique identifier from the end of the youtube URL.
- Call the script:
- Code: Select all
./youtube.sh ID OutputFLV.flv
- Convert the FLV into an AVI (it is possible to convert from FLV->GIF, but the quality is horrible):
- Code: Select all
mencoder -oac pcm -ovc lavc -o OutputAVI.avi OutputFLV.flv
- You may now select the parts that you want to include by running avidemux, if you wish. Use the A/B buttons on the bottom right to select the parts and save the file.
- Now make a temporary file to save the individual frames from your AVI:
- Code: Select all
mkdir ~/gif && cd ~/gif
- Now, use Mplayer to convert EVERY frame into a jpeg:
- Code: Select all
mplayer ~/OutputAVI.avi -vo jpeg
- You can now edit out the frames you do and don't want.
- Now, all that is left to do is convert the frames to a GIF!
- Code: Select all
convert -enhance -resize 150x150 -delay 4 -loop 0 *.jpg ~/Desktop/FinalOutput.gif
Your computer will probably freeze for a while at this point. Don't panic, just leave it to do its thing.
The options are: resize (set to 150px*150px here), delay (4ms before starting), loop (0=infinite) and *.jpg which looks for every sequential JPG. Note that the file will be on your Desktop now.
Voila! You have a high quality GIF!

Example:
I created this tutorial whilst learning how to convert avis for Saggy's requested avatar/sig. Note, the file is 6.3Mb as I haven't optimised it yet.

Youtube grabbing script adapted from: http://www.chuckcaplan.com/blog/archives/2007/07/how_to_convert_1.html