用FFmpeg制作高质量的GIF

About two years ago, I tried to improve the support of the GIF encoding in FFmpeg to make it at least decent. This notably led to the addition of the transparency mechanism in the GIF encoder. While this is not always optimal depending on your source, it is in the most common cases. Still, this was merely an attempt to prevent shaming the encoder too much.

大约两年前,我试图改善FFmpeg中对GIF编码的支持,使其至少是体面的。这特别导致了在GIF编码器中增加了透明机制。虽然这并不总是最理想的,取决于你的来源,但在最常见的情况下,它是最好的。不过,这也只是为了防止对编码器进行过多的羞辱。

But recently at Stupeflix, we needed a way to generate high quality GIF for the Legend app, so I decided to work on this again.

但最近在Stupeflix,我们需要一种方法来为Legend应用程序生成高质量的GIF,所以我决定再次从事这项工作。

All the features presented in this blog post are available in FFmpeg 2.6, and will be used in the next version of Legend app (probably around March 26th).

这篇博文中介绍的所有功能在FFmpeg 2.6中都有,并将在下一个版本的Legend应用中使用(可能在3月26日左右)。

TL;DR: go to the Usage section to see how to use it.

TL;DR:去使用部分看看如何使用它。

Initial improvements (2013)

初步改进(2013年)

Let's observe the effect of the transparency mechanism introduced in 2013 in the GIF encoder:

让我们观察一下2013年在GIF编码器中引入的透明机制的效果。

ffmpeg -v warning -ss 45 -t 2 -i big_buck_bunny_1080p_h264.mov -vf scale=300:-1 -gifflags -transdiff -y bbb-notrans.gif
ffmpeg -v warning -ss 45 -t 2 -i big_buck_bunny_1080p_h264.mov -vf scale=300:-1 -gifflags +transdiff -y bbb-trans.gif
ls -l bbb-*.gif
-rw-r--r-- 1 ux ux 1.1M Mar 15 22:50 bbb-notrans.gif
-rw-r--r-- 1 ux ux 369K Mar 15 22:50 bbb-trans.gif

centerimg

This option is enabled by default, so you will only want to disable it in case your image has very much motion or color changes.

这个选项是默认启用的,所以你只想在你的图像有非常多的运动或颜色变化的情况下禁用它。

The other implemented compression mechanism was the cropping, which is basically a way of allowing to redraw only a sub rectangle of the GIF and keep the surrounding untouched. In case of a movie, it is rarely very useful. I will get back to this later on.

另一个实现的压缩机制是裁剪,这基本上是一种允许只重绘GIF的一个子矩形而保持周围不被触及的方法。对于电影来说,它很少有很大的作用。我稍后会回到这个问题上。

But anyway, since then, I didn't make any progress on it. And while...

开通本站会员,查看完整译文。

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.123.4. UTC+08:00, 2024-04-20 13:30
浙ICP备14020137号-1 $访客地图$