[FFmpeg-trac] #9872(undetermined:new): WebP vs PNG alpha

FFmpeg trac at avcodec.org
Thu Aug 11 18:13:15 EEST 2022


#9872: WebP vs PNG alpha
-------------------------------------+-------------------------------------
             Reporter:  Jozef        |                    Owner:  (none)
  Chutka                             |
                 Type:  defect       |                   Status:  new
             Priority:  normal       |                Component:
                                     |  undetermined
              Version:  unspecified  |               Resolution:
             Keywords:  scale , png  |               Blocked By:
  , webp , alpha                     |
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
Description changed by Jozef Chutka:

Old description:

> using ffmpeg version 2022-07-31-git-1368b5a725-full_build-www.gyan.dev
>
> Attached x.png and x.webp (webp created from png) have transparent
> background covered by white X shape.
>
> For some reason FFmpeg scale filter treats the x.png and x.webp
> differently.
>
> Applying scale filter on the x.webp, causes the output video alpha around
> the X shape to be premultiplied and so renders with ugly edges.
>
> Following commands, esp. out-webp-scale.png output demonstrates the
> issue:
>
> ```
> ffmpeg -filter_complex "color=white:200x200[b];movie=x.png,[b]overlay" -y
> out-png.png
>
> ffmpeg -filter_complex
> "color=white:200x200[b];movie=x.png,scale=200:200,[b]overlay" -y out-png-
> scale.png
>
> ffmpeg -filter_complex "color=white:200x200[b];movie=x.webp,[b]overlay"
> -y out-webp.png
>
> ffmpeg -filter_complex
> "color=white:200x200[b];movie=x.webp,scale=200:200,[b]overlay" -y out-
> webp-scale.png
> ```
>
> I tried all possible scale filter flags, and also format changing (before
> and after scale) but no luck to achieve the same result. I am able to un-
> premultipy the problematic one with `unpremultiply` filter but I would
> like to avoid it.
>
> I wonder if this is a bug or an expected behaviour.

New description:

 using ffmpeg version 2022-07-31-git-1368b5a725-full_build-www.gyan.dev

 Attached x.png and x.webp (webp created from png) have transparent
 background covered by white X shape.

 For some reason FFmpeg scale filter treats the x.png and x.webp
 differently.

 Applying scale filter on the x.webp, causes the output video alpha around
 the X shape to be premultiplied and so renders with ugly edges.

 Following commands, esp. out-webp-scale.png output demonstrates the issue:

 {{{
 ffmpeg -filter_complex "color=white:200x200[b];movie=x.png,[b]overlay" -y
 out-png.png

 ffmpeg -filter_complex
 "color=white:200x200[b];movie=x.png,scale=200:200,[b]overlay" -y out-png-
 scale.png

 ffmpeg -filter_complex "color=white:200x200[b];movie=x.webp,[b]overlay" -y
 out-webp.png

 ffmpeg -filter_complex
 "color=white:200x200[b];movie=x.webp,scale=200:200,[b]overlay" -y out-
 webp-scale.png
 }}}

 I tried all possible scale filter flags, and also format changing (before
 and after scale) but no luck to achieve the same result. I am able to un-
 premultipy the problematic one with `unpremultiply` filter but I would
 like to avoid it.

 I wonder if this is a bug or an expected behaviour.

--
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/9872#comment:1>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list