How to generate gif from avi using ffmpeg?

I am trying to extract part of a video into an animated gif using the following command:

ffmpeg -i video.avi -t 5 out.gif 

It generates an animated gif, but the quality is insane. However, when I generate a gif image using:

ffmpeg -i video.avi -t 10 out%d.gif

It generates acceptable quality gif images. How can I generate an animated gif using the first command, but with the same quality as the second command?

+44
ffmpeg
May 21 '11 at 2:04 AM
source share
2 answers

I had a similar problem trying to create a high quality animated gif from a series of images extracted from a movie.

For some reason, the animated gif generated with ffmpeg contains only 103 colors, allowing the use of a fixed color palette of a level 256 system, which leads to a terrifying result. My decision was instead

 ffmpeg -i video.avi -t 10 out%02d.gif 

then

 gifsicle --delay=10 --loop *.gif > anim.gif 

The quality is then good. You can find the gifsicle here

Edit: Updated post to reflect Alex Kahn's suggestions.

+61
May 10 '12 at 12:17 a.m.
source share
โ€” -

I haven't done an animated GIF yet, but you can try using the bit rate option to indicate quality, even though it is an image (and apparently without a bid). The quality of the thumbnails corresponds to the -b option. If you, crazy, mean "insanely bad", you can specify a very high bit rate and bit rate (you are not sure if you use the source vbr or cbr). (or vice versa if you mean that this is too good and you want to limit the size)

'-b', '10000000','-bt', '20000000'

Alternatively, you can also resize using the -s option, which will take on the usual representation of dimensions, such as "1920X1200".

It really depends on the bitrate and compression of the source material and what you are hoping for is a gif. Perhaps consider providing more information than the โ€œinsane," but I think this will give you a good start anyway. Good luck.

0
May 21 '11 at 2:21
source share



All Articles