[FFmpeg-devel] Lossy GIF encoding

Moritz Barsnick barsnick at gmx.net
Fri Feb 15 20:43:53 EET 2019


On Fri, Feb 15, 2019 at 09:01:40 +0000, Kornel wrote:

> The main problem I have now is that the existing GIF codec receives
> frames already converted to AV_PIX_FMT_RGB8 or similar 8-bit format.
> When working with 8bpp heavily-dithered input, the lossy compression
> struggles to find runs of similar pixels, so it isn't very effective.
[...]
> Alternatively, would it be OK to create a separate codec just for
> lossy compression? I would create a new GIF codec, define it under a
> new name, and declare it always takes AV_PIX_FMT_RGB24 or
> AV_PIX_FMT_RGBA. Is that a good approach?

That is already the case with other codecs which are similar enough:
They define more than one "AVCodec ff_foo_encoder =" in the main C
file, and share as many functions as possible. So if your new encoder
is chosen, e.g. with "-c:v giflossy", its properties and callbacks will
be used, while being "gif" at heart. At the same time, you don't need
to duplicate all the stuff from the existing gif.c which you would need
anyway.

All this assuming your implementation does share enough stuff from the
existing gif encoder.

Moritz


More information about the ffmpeg-devel mailing list