How do I convert an animated GIF to a YouTube friendly video format?

The ImageMagick convert program can split up animated GIFs. e.g. given the existence of a file 'foo.gif', I can run:

convert foo.gif foo.png

and it will create files foo-0.png, foo-1.png, etc, one for each frame. If you have more digits, then use the following syntax, for example with 4 digits:

convert foo.gif foo%04d.png

You could then use FFmpeg to build those into a movie.

ffmpeg -f image2 -r framerate -i foo-%d.png -c:v libx264 -pix_fmt yuv420p output.mp4

To change the quality of the resulting video, add the -crf option, e.g. -crf 23, where lower means better quality. Sane values are between 18 and 28, but since the GIF quality shouldn't be too good in the first place, you probably won't need this option.

As of 2013, recent versions of ffmpeg can accept animated gifs as input directly.

ffmpeg -r framerate -i input.gif -c:v libx264 -pix_fmt yuv420p output.mp4

Try this Open Source software http://www.virtualdub.org

Open your .gif as a video file... then save as .avi


Just

ffmpeg -i input.gif output.mp4

(taken from @framp's comment on @John Fouhy's answer above)

Don't know about YouTube, but the codec can be specified with the -c:v options (see ffmpeg -codecs for the list of codecs).

This codec for example imports well into Final Cut:

ffmpeg -i input.gif -c:v qtrle output.mov