如何使用ffmpeg从avi生成gif? [英] How to generate gif from avi using ffmpeg?

查看:318
本文介绍了如何使用ffmpeg从avi生成gif?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下命令将视频的一部分提取到动画GIF中:

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

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

它生成动画GIF,但质量是疯狂的。但是当我使用以下方式生成gif图像时:

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

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

它可以产生可接受的gif图像质量。我如何使用第一个命令生成动画GIF,但质量与第二个命令相同?

It generates acceptable quality of gif images. How can i generate animated gif using the first command but the same quality as the second command?

推荐答案

我有一个类似的问题从电影提取的一系列图像中生成高质量的动画GIF。

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

由于某些原因,使用ffmpeg生成的动画GIF只包含103种颜色,使用固定的256级系统调色板可以产生可怕的结果。我的解决方案是

For some reasons the animated gif generated with ffmpeg only contains 103 colors assumable using a fixed 256 level system color palette resulting in horrific result. My solution was instead

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

然后

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

质量是相当不错的。你可以找到gifsicle here

Quality is then quite good. You can find gifsicle here

编辑:更新了帖子以反映Alex Kahn的建议。

Updated the post to reflect Alex Kahn's suggestions.

这篇关于如何使用ffmpeg从avi生成gif?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆