Opened 4 years ago

Closed 3 years ago

#8861 closed defect (fixed)

Creating GIF with full transparent background from PNGs with semi-transparent pixels, somehow causes this outline

Reported by: karl-police Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: paletteuse
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug: There's an unwanted outline, how can I fix it? I created a GIF from PNGs with semi-transparent pixels and it had this outline. When using transparency_color I was able to change the color, but I couldn't get rid of the outline.

This doesn't happen with APNG, but APNG supports semi-transparent pixels. I need it as a GIF though.

How to reproduce:

ffmpeg version = ffmpeg version 4.3.1
built on downloadable .exe from ffmpeg.org

Commands used:

ffmpeg -y -i "sprite2/amongus_player_walk_00%02d.png" -lavfi fps=50,palettegen palette.png


ffmpeg -i "sprite2/amongus_player_walk_00%02d.png" -i palette.png -lavfi "fps=50,paletteuse" -y output.gif

One of the original images looks like this:https://i.imgur.com/aCZxKuW.png

the output is this: https://i.imgur.com/9iuJ14K.gif as you can see there's this weird outline, that I'm trying to get rid of.

Attachments (2)

sprite2.zip (83.2 KB ) - added by karl-police 4 years ago.
sprite3.zip (68.8 KB ) - added by karl-police 4 years ago.

Download all attachments as: .zip

Change History (22)

by karl-police, 4 years ago

Attachment: sprite2.zip added

comment:1 by Carl Eugen Hoyos, 4 years ago

Component: ffmpegavfilter
Keywords: paletteuse added
Priority: wishnormal

This has very little similarities with a valid ticket.

Does paletteuse=bayer fix the issue for you?

Last edited 4 years ago by Carl Eugen Hoyos (previous) (diff)

in reply to:  1 comment:2 by karl-police, 4 years ago

Replying to cehoyos:

This has very little similarities with a valid ticket.

Does paletteuse=bayer fix the issue for you?

yep it does, how so?

in reply to:  1 comment:3 by karl-police, 4 years ago

Replying to cehoyos:

This has very little similarities with a valid ticket.

Does paletteuse=bayer fix the issue for you?

another question

uhh I set the fps 12 with bayer, and it's doing this https://i.imgur.com/trtfjhQ.gif

ffmpeg -i "sprite2/amongus_player_walk_00%02d.png" -i palette.png -lavfi "fps=12,paletteuse=bayer" -y output.gif

how do I fix that?

Last edited 4 years ago by karl-police (previous) (diff)

comment:4 by Carl Eugen Hoyos, 4 years ago

See #7902.

in reply to:  4 ; comment:5 by karl-police, 4 years ago

Replying to cehoyos:

See #7902.

Removing the first frame check?

in reply to:  5 comment:6 by Carl Eugen Hoyos, 4 years ago

Replying to karl-police:

Replying to cehoyos:

See #7902.

Removing the first frame check?

I don't understand the question.

comment:7 by pdr0, 4 years ago

I think that artifact is from the fps filter, and you're dropping frames. It looks ok if you use -r as an input option

eg.

ffmpeg -r 25 -i "sprite2/amongus_player_walk_00%02d.png" -i palette.png -lavfi "paletteuse=bayer" r25_output.gif

12fps works too, I just left it at 25fps for the example
https://imgur.com/a/5MNxLQI

Last edited 4 years ago by pdr0 (previous) (diff)

in reply to:  7 ; comment:8 by karl-police, 4 years ago

Replying to pdr0:

I think that artifact is from the fps filter, and you're dropping frames. It looks ok if you use -r as an input option

eg.

ffmpeg -r 25 -i "sprite2/amongus_player_walk_00%02d.png" -i palette.png -lavfi "paletteuse=bayer" r25_output.gif

12fps works too, I just left it at 25fps for the example
https://imgur.com/a/5MNxLQI

What does -r do? And why exactly 25?

in reply to:  7 ; comment:9 by Carl Eugen Hoyos, 4 years ago

Replying to pdr0:

I think that artifact is from the fps filter

This seems unlikely as the artefacts are a known issue.

in reply to:  8 comment:10 by pdr0, 4 years ago

Replying to karl-police:

What does -r do? And why exactly 25?

-r as an input option (before the -i) sets the input framerate . An image sequence can be any framerate . I randomly chose 25. Choose the framerate you want for the speed of the animation. -vf fps will duplicate or drop frames to achieved the desired output fps, based on the input framerate . It does not make sense that -vf fps should cause that artifact

in reply to:  9 ; comment:11 by pdr0, 4 years ago

Replying to cehoyos:

Replying to pdr0:

I think that artifact is from the fps filter

This seems unlikely as the artefacts are a known issue.

Yes, it seems unlikely, and according to what -vf fps is supposed to do

Excluding the fps filter, there are no artifacts. Using the fps filter, there are artifacts. Regardless of including or excluding -r as an input option. How else would you explain this observation?

in reply to:  11 ; comment:12 by karl-police, 4 years ago

Replying to pdr0:

Replying to cehoyos:

Replying to pdr0:

I think that artifact is from the fps filter

This seems unlikely as the artefacts are a known issue.

Yes, it seems unlikely, and according to what -vf fps is supposed to do

Excluding the fps filter, there are no artifacts. Using the fps filter, there are artifacts. Regardless of including or excluding -r as an input option. How else would you explain this observation?

but why are there these artifacts?

in reply to:  11 comment:13 by karl-police, 4 years ago

Replying to pdr0:

Replying to cehoyos:

Replying to pdr0:

I think that artifact is from the fps filter

This seems unlikely as the artefacts are a known issue.

Yes, it seems unlikely, and according to what -vf fps is supposed to do

Excluding the fps filter, there are no artifacts. Using the fps filter, there are artifacts. Regardless of including or excluding -r as an input option. How else would you explain this observation?

but why are there these artifacts?

in reply to:  12 ; comment:14 by Carl Eugen Hoyos, 4 years ago

Replying to karl-police:

but why are there these artifacts?

Because of a known bug in the gif encoder that is not related to the behaviour of the paletteuse option dither.

in reply to:  14 comment:15 by karl-police, 4 years ago

Replying to cehoyos:

Replying to karl-police:

but why are there these artifacts?

Because of a known bug in the gif encoder that is not related to the behaviour of the paletteuse option dither.

and is that planned to be fixed?

comment:16 by karl-police, 4 years ago

Is it possible in FFMPEG to do these color replacements?

As example on https://i.imgur.com/GotzcqY.gif

you see the "Red, Green, Blue" templates. And, apperantly you split them up and then you define another RGB color to replace all with. I'm not sure how that is called. A general term for it seems to be color interpolation, but that just means, math with colors or something.

comment:17 by karl-police, 4 years ago

Is it possible in FFMPEG to do these color replacements?

As example on hhttps://i.imgur.com/GotzcqY.gif

you see the "Red, Green, Blue" templates. And, apperantly you split them up and then you define another RGB color to replace all with. I'm not sure how that is called. A general term for it seems to be color interpolation, but that just means, math with colors or something.

comment:18 by karl-police, 4 years ago

so is -r 12 better than fps=12
or is that just when it's very slow?
these artifacts?

comment:19 by karl-police, 4 years ago

when using "bayer" to prevent these outlines, though what can happen, let's say the entire thing would be a bit more yellow. That the entire image gets dithered, which is something I want to prevent.

https://trac.ffmpeg.org/attachment/ticket/8861/sprite3.zip

Last edited 4 years ago by karl-police (previous) (diff)

by karl-police, 4 years ago

Attachment: sprite3.zip added

comment:20 by Elon Musk, 3 years ago

Resolution: fixed
Status: newclosed

Fixed in 835eb0a556d678dd65bb1978519c4d62d93c37c4

The black outline got little green tint if dithering is used but that is covered in different open bug report.

Note: See TracTickets for help on using tickets.