[FFmpeg-devel] [PATCH] WebP native muxer bugfix: frames should have alpha blending off

Michael Niedermayer michael at niedermayer.cc
Tue Jul 14 03:48:07 CEST 2015

On Tue, Jul 14, 2015 at 12:20:43AM +0000, Urvang Joshi wrote:
> Hi Michael,
> How about sending the blend method info using side_data in the AVFrame?

the encoders input are AVFrames, the encoder does not output AVFrames
so you cannot send anything with an AVFrame from the encoder to
the muxer.
The data struct between encoder and muxer is a AVPacket
the ANMF chunk which carries the blend information could be
put like any other chunk in AVPacket.data together with the rest of
the frame.
I think thats cleaner than putting strings in side data but such
side data would also work 

> Here's the patch using that method. If this looks fine, I can separate it
> out into avformat/* changes and avcodec/* changes.

> Two cases here:
> (1) With the default encoder options, all the frames that the native muxer
> gets are fully reconstructed frames, and they should NOT be alpha-blended
> with the previous frames.
> As per the WebP container spec
> https://developers.google.com/speed/webp/docs/riff_container#animation,
> ANMF chunk should specify blending method = do not blend (and disposal
> method = do not dispose).
> However, the native muxer was wrongly setting blending method = use
> alpha blending for this case.
> This bug can be reproduced by converting a source with transparency
> (e.g. animated GIF with transparency) to an animated WebP, and viewing
> it with vwebp.

> (2) In presence of options like 'cr_threshold' and 'cr_size', the frames
> may be modified to introduce some transparent pixels and they SHOULD be
> alpha-blended with the previous frames. However, such introduction of
> transparent pixels should only be allowed when the original frame didn't
> already contain some transparent pixels.

this seems not to work:

./ffmpeg -i matrixbench_mpeg2.mpg -cr_threshold 10000 -cr_size 16 -t 1 -loop 2 -vcodec libwebp -flags +bitexact ref.webp
apply patch
./ffmpeg -i matrixbench_mpeg2.mpg -cr_threshold 10000 -cr_size 16 -t 1 -loop 2 -vcodec libwebp -flags +bitexact new.webp
./ffmpeg -i matrixbench_mpeg2.mpg                                 -t 1 -loop 2 -vcodec libwebp -flags +bitexact new-nocr.webp

ls -alF *.webp
-rw-r----- 1 michael michael 191978 Jul 14 03:29 new-nocr.webp
-rw-r----- 1 michael michael 191978 Jul 14 03:15 new.webp
-rw-r----- 1 michael michael 139126 Jul 14 03:12 ref.webp

theres no transparency in matrixbench_mpeg2.mpg, yet the cr_* options
no longer work


Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

You can kill me, but you cannot change the truth.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150714/308cf001/attachment.sig>

More information about the ffmpeg-devel mailing list