Search code examples
videoffmpegvideo-processing

Bad quality when overlaying PNG with FFMpeg


I'm trying to overlay a PNG over an animated GIF using FFMpeg.

The image is outputted correctly, but both the GIF and PNG are considerably lower quality. I've tried a few things, but can't figure it out.

I have:

ffmpeg
-i animated.gif
-i overlay.png
-filter_complex 'overlay=10:10, palettegen'
palette.png -y

ffmpeg
-i animated.gif
-i overlay.png
-i palette.png
-filter_complex 'overlay=10:10, paletteuse'
animated-overlay.gif -y

What am I doing wrong?


Solution

  • Use the format overlay option to avoid the default conversion to yuv420p in overlay filter.

    overlay=10:10:format=auto
    

    See the overlay filter documentation for other accepted values.