[FFmpeg-trac] #7902(undetermined:new): GIF transparent frames overlapping
FFmpeg
trac at avcodec.org
Fri Mar 27 03:27:39 EET 2020
#7902: GIF transparent frames overlapping
-------------------------------------+-------------------------------------
Reporter: kolopo | Owner:
Type: defect | Status: new
Priority: normal | Component:
| undetermined
Version: git-master | Resolution:
Keywords: gif | Blocked By:
disposal |
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Changes (by RedError):
* cc: rederrorsuru@… (added)
* keywords: gif alpha => gif disposal
Comment:
When creating a gif with transparency with ffmpeg, the first frame has a
wrong "Gif Disposal" value (1 "Do Not Dispose" instead of 0 "No disposal"
or 2 "Restore to Background" like all the other frames) and thus is always
overlayed on the second frame.
How to reproduce (ffmpeg version git-2020-03-24-e5d25d1):
{{{
ffmpeg -i "slowsmoke.gif" -gifflags 0 -vf "[0:v] split [a][b]; [a]
palettegen [p]; [b][p] paletteuse [r]" "slowsmoke ffmpeg.gif" -y
}}}
Input slowsmoke.gif:
[[Image(https://i.ibb.co/mzSx63y/slowsmoke.gif)]]
Output "slowsmoke ffmpeg.gif":
[[Image(https://i.imgur.com/cnd96Wq.gif)]]
Additional details:
* The disposal info of the faulty gif can be viewed in advanced gif
editors. For example, Gimp shows the second frame as being "combine".
'''Editing that information allows the gif to be fixed.''' This proves
that it is indeed the frame disposal that is in cause.
[[Image(https://i.imgur.com/GFD9AgG.png)]]
* -gifflags +offsetting leaves additional traces for next frames (by
reducing the frame draw area) as underlined in the OP, so it's better
disabled in this case with -gifflags 0 like I did, but I don't think
that's directly related to the underlying first frame disposal issue.
[[Image(https://i.imgur.com/MNtPeA1.gif)]]
* -gifflags -transdiff or +transdiff cannot actually do anything for
transparent gifs, because of the presence of transparency in the refresh
area (cannot combine layers based on transparent holes), so it's also not
directly related.
* The Disposal method is different with non-transparent gifs, so the
encoding error might be close to where the difference in Disposal is
handled when saving a frame/first frame. [https://i.imgur.com/usgKA0J.png
Example]
* Explanation of "Do Not Dispose" Gif Disposal: «any pixels not covered up
by the next frame continue to display.»
http://webreference.com/content/studio/disposal.html Numerical values of
each disposal mode taken from: https://www.w3.org/Graphics/GIF/spec-
gif89a.txt
png's alpha transparency was unrelated so I removed the keyword.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/7902#comment:4>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list