images – How to avoid losing color with palettegen in ffmpeg?
I’ve been messing around with turning video clips to gifs lately, it’s been fairly fun, discovered a lot of interesting ways to make the gifs smaller without losing any meaningful quality, or interesting quality vs filesize tradeoff techniques.
One of these is using color palettes with palettegen and paletteuse, which can be a very powerful tool for gif optimization. However I noticed something that’s extremely annoying.
When creating and using color palettes this way, a lot of color information seems to get lost; that wouldn’t be getting lost if the palettes were not being used.
In particular highly saturated colors (especially reds) seem to fall victim to this.
To showcase this, here is a comparison image:
And as separate images:
This is a png conversion of the first frame from the video clip, the colors were converted well enough that I couldn’t see any differences from the source at all with the help of -vf zscale=min=709,format=gbrp (that filter was not used for the gifs)

this is almost lossless, in fact if the image is downscaled a little (hides dither patterns) it appears as if it were lossless!

also almost lossless, but overall image is a little smidge darker because of the dither patterns.

Serious loss of color. Pay particular attention to the green frog, the red earrings and the teal highlights in the girl’s hair. Also if you compare it side-by-side to any of the other images you will easily see that there is a great degree of color difference. This result is not terrible by any means, but compared to the other two it is quite lacking, and this is after I tweaked it to the best of my ability (the settings I used provided the closest color match to the original with palettegen/paletteuse, changing stats_mode or dither pattern to anything else than what I’m using here tended to make things worse)

Is there a way to get relatively the same color quality with palettegen and paletteuse as I can without it?
Read more here: Source link

