2009-05-21

Animated gif to avi/flv

Using gifsicle to unoptimize the animated GIF and split it into frames, and ffmpeg to build a video:
gifsicle -U --explode "input.gif"
for f in *.gif.* ; do mv "$f" "$f.gif" ; done
ffmpeg -r 25 -i "input.gif.%03d.gif" -sameq -s 320x240 output.flv
If we need to do some padding with black:
ffmpeg -i input.file -s 320x180 -padtop 30 -padbottom 30 output.file
UPDATE: With newer ffmpeg (for example, ffmpeg 0.6.90), this becomes:
ffmpeg -i input.file -vf "scale=320:180,pad=320:240:0:30" output.file
I don't use convert (ImageMagick) to split frames, because gifsicle appears to work faster and require less memory.

(читать по-русски)