问题
Is there any way to convert an animated gif to a video format (e.g. .avi
) on Linux?
I have already tried
ffmpeg -i thegif.gif thevideo.avi
but all I get is the first image of the video.
回答1:
I can suggest combination of imagemagick and ffmpeg
do this to extract each frame as png/jpeg
$magick> convert 'images.gif[0]' image.png
Do this to convert images to movie sequence
ffmpeg -f image2 -i image%d.jpg video.mpg
More help on commands
http://www.imagemagick.org/script/command-line-processing.php
http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs
http://electron.mit.edu/~gsteele/ffmpeg/
回答2:
ffmpeg's gif input doesn't work too well. It's usually easier to unpack the gif frames with convert (from ImageMagick) and process these with ffmpeg:
convert some.gif some%05d.png
ffmpeg -i some%05d.png some.avi
rm some*.png
回答3:
If you like to have a certain framerate as input because the resulting video is to fast or to slow
ffmpeg -r 'xx' -i some%05d.png some.avi
where xx is the input framerate.
回答4:
If you dont want temporary files, you can try mencoder:
mencoder myfile.gif -mf fps=25 -o myfile.avi -ovc lavc -lavcopts vcodec=mpeg4
回答5:
If you like to have a loop as output
ffmpeg -loop 1 -t x -i some%05d.png some.avi
where x is the time the video should run in seconds.
Source
来源:https://stackoverflow.com/questions/3212821/animated-gif-to-avi-on-linux