[FFmpeg-user] PNGs with transparent pixels to GIF

pdr0 pdr0 at shaw.ca
Sun Dec 20 21:37:14 EET 2020

MediaMouth wrote
>> eg.
>> ffmpeg -r 12 -i toile4-4-%d.png -filter_complex
>> "palettegen[PG],[0:v][PG]paletteuse" toile4.gif
> Following up on the documentation links provided, I wasn't able to work
> out what the details of your "-filter_complex" entries were about


filter_complex "connects" multiple inputs and/or outputs. The names in
brackets are named input or output "pads". They are similar to variable
names . eg. [PG] could have been called [label1]. [0:v] means 1st file
(numbering starts with zero), video stream. Similary [0:a] would mean first
file, audio stream . There are reserved syntax for video and audio streams.
This should be in the documetantion on stream numbering

The first input node is omitted because there is only one input into the
filter graph. The output node is also omitted, because there is only 1
choice of output. This really means [out] 

-filter_complex "[0:v]palettegen[PG],[0:v][PG]paletteuse[out]" -map [out]

> I ran it against a test png seq it did work  -- I got a gif that preserved
> the PNG transparency -- but I got some artifacts.
> Attaching both the PNG seq and the resulting GIF in PngSeq.zip (below)
> (hopefully it posts)
> The command I used was based on your example:
>> ffmpeg -i PngSeq/Frame_%05d.png -framerate 12 -filter_complex
>> "palettegen[PG],[0:v][PG]paletteuse" PngSeq.gif
> Questions:
> 	- What caused / how to avoid the artifacts?
> 	- What is PG in your example?

I don't see the attachment, but 2 common artifacts for gif in general are
quantization artifacts (gif only has 256 colors max), and the alpha channel
can look very poor and binarized. Or dithering artifacts. There are
different algorithms for dithering 

"PG" is explained above

Sent from: http://www.ffmpeg-archive.org/

More information about the ffmpeg-user mailing list