[FFmpeg-devel] [PATCH] Fix for paletteuse to support transparency

Bjorn Roche bjorn at giphy.com
Tue Oct 10 23:23:46 EEST 2017


On Sat, Oct 7, 2017 at 9:53 AM, Carl Eugen Hoyos <ceffmpeg at gmail.com> wrote:

> 2017-10-06 23:23 GMT+02:00 Carl Eugen Hoyos <ceffmpeg at gmail.com>:
> > 2017-10-06 22:59 GMT+02:00 Bjorn Roche <bjorn at giphy.com>:
> >
> >>  libavfilter/vf_paletteuse.c | 175
> >
> > Works fine for me
>
> I had tested with the sample from ticket #503 yesterday.
>
> Using the following sample:
> http://samples.ffmpeg.org/FLV/flash_with_alpha/300x180-Scr-f8-056alpha.flv
> I get less nice results:
> $ ffmpeg -i 300x180-Scr-f8-056alpha.flv -vframes 1 -vf palettegen pal.png
> $ ffmpeg -i 300x180-Scr-f8-056alpha.flv -i pal.png -lavfi paletteuse
> -vframes 1 out.png
> Transparency in the output file is not correct, I wonder if the line
> "if (c1[0] == 0 && c2[0] == 0" should be more something like
> "if (c1[0] < 128 && c2[0] < 128)" (or with a threshold variable).
>
> The results get worse with more frames and apng output:
> Large blocks "disappear" from the output file, this looks
> quite nice without your patch (but without transparency).
>
>
Thanks for checking that. While working on this, I wasn't sure what to
consider transparent in the source image, so I gave your threshold
suggestion a try setting the threshold as a #define and it works fine on
that file and my tests. Everything I've tested so far looks fine, but I am
not really sure what (if any) impact this has on dither.

I don't know how to make that a configurable argument, but I'll take a look.

-- 


Bjorn Roche

Sr. Video Pipeline Engineer

bjorn at giphy.com


More information about the ffmpeg-devel mailing list