1

The png codec in ffmpeg can result large pngs in certain cases. I know pngs are supposed to be non-lossy but there are libraries such as libpngquant that difference between the pixel and the value predicted by the average filter.

Ffmpeg doesn't seem to support these libraries. It will be great if it could. Does anyone know if this is planned? How easy is it to port libpngquant over to ffmpeg's png encoder?

0

I'm not aware of anyone working on this.

Is this the library you're referring to - https://pngquant.org/lib/?

This appears to generate a palette and then perform the usual PNG encoding upon the palettized image. If so, this can already be reproduced in FFmpeg.

ffmpeg -i image -filter_complex palettegen[pal];[0][pal]paletteuse,format=pal8 out.png

See docs for paletteuse for dithering options.


If the specific algorithm were to be added to FFmpeg, it would be as a libav filter, not as changes to the PNG encoder. Although given existing functionality, most acceptable way forward is to improve the palettegen/use filters if their quality isn't acceptable.

  • Thanks for explaining this. Yes that is the site for libpngquant. I’ll compare ffmpeg palletegen with libpngquant and see if it works better. – user984896 Jun 28 '18 at 6:00
  • It works, but PSNR is very bad. command to test: ffmpeg -y -i 1.png -filter_complex "palettegen=reserve_transparent=1[pal];[0][pal]paletteuse=dither=bayer" 3.png 2>&1 | tail -2 ; ffmpeg -y -i 3.png -i 1.png -filter_complex "psnr" -f null /dev/null 2>&1 | tail -1; ls -lh {1,3}.png; open {1,3}.png – user984896 Jun 28 '18 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.