Opened 12 days ago

Closed 12 days ago

Last modified 11 days ago

#11424 closed defect (worksforme)

Colors distorted converting from APNG to GIF

Reported by: idest Owned by:
Priority: normal Component: ffmpeg
Version: unspecified Keywords: colorspace
Cc: idest, MasterQuestionable Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: yes

Description (last modified by idest)

Try converting the attached animated PNG file, spiral.png, into a GIF animation with the command

ffmpeg -i spiral.png spiral.gif

Notice that in the resulting file, spiral.gif (also attached), colors are distorted: almost all the curves are in yellow.

Reported FFMpeg version: N-118325-gea381285e7-20250119,
OS: Windows 10 Home.

Attachments (2)

spiral.png (32.4 KB ) - added by idest 12 days ago.
spiral.gif (111.6 KB ) - added by idest 12 days ago.

Download all attachments as: .zip

Change History (8)

by idest, 12 days ago

Attachment: spiral.png added

by idest, 12 days ago

Attachment: spiral.gif added

comment:1 by idest, 12 days ago

Description: modified (diff)

comment:2 by Leo Izen, 12 days ago

This is caused by the automatic converstion from rgb24 to bgr8, which is the default for the gif encoder. bgr8 cannot represent the colors correctly. Use this instead:

`
ffmpeg -i spiral.png -vf 'split[v],palettegen,[v]paletteuse' spiral.gif
`

The original picture only has 60 colors so this shouldn't create any loss.

Version 0, edited 12 days ago by Leo Izen (next)

comment:3 by idest, 12 days ago

Thank you for the explanation, Leo, your command produces the desired result.

comment:4 by MasterQuestionable, 12 days ago

Analyzed by developer: set
Cc: MasterQuestionable added
Keywords: colorspace added
Resolution: worksforme
Status: newclosed
Summary: Colors get distorted when converting from an animated PNG into an animated GIFColors distorted converting from APNG to GIF

͏    Should qualify as part of a future enhancement.
͏    (Improve handling of default colorspace selection)

comment:5 by Balling, 11 days ago

Enchancement like this is quite hard. Would need analysis how many colors are there, what gif encoding to use — image magik does it...

comment:6 by MasterQuestionable, 11 days ago

͏    Not attempt for Palette optimization (to fit GIF).
͏    Merely the simple logic branching to use more sensible pixel format (colorspace).
͏    Avoid insensible alike: https://trac.ffmpeg.org/ticket/11222

Note: See TracTickets for help on using tickets.