[FFmpeg-devel] [PATCH] avcodec[/format]/webpenc: use WebPAnimEncoder API to generate animated WebP

Michael Niedermayer michaelni at gmx.at
Thu Apr 23 23:51:15 CEST 2015


On Thu, Apr 16, 2015 at 10:40:14PM +0000, Urvang Joshi wrote:
> On Thu, Apr 16, 2015 at 3:09 PM James Almer <jamrial at gmail.com> wrote:
> 
> > On 16/04/15 4:18 PM, Urvang Joshi wrote:
> > > Hi,
> > > Here's the patch without whitespace changes.
> > >
> > > Thanks,
> > > Urvang
> >
> > This patch doesn't apply cleanly. Looks like something weird with the
> > indentation still.
> > Was this patch handmade? It says the hash for libwebpenc.c is 95d56ac
> > (same as git head),
> > but the contents of the patch don't match.
> >
> 
> Sorry, I should have mentioned that it was created with
> "--ignore-all-space" option, so using the same option when applying the
> patch would have worked.
> 
> But to avoid any confusion, here's the re-created patch, that should apply
> cleanly with just 'git am'.
> 
> 
> >
> > After fixing the conflicts and compiling the patch seems to work, but the
> > resulting
> > animated webp files are smaller than those using the native muxer using
> > the default
> > encoding and muxing settings.
> > Is this because the muxing done by libwebpmux is different, or are the
> > quality defaults
> > changed in any way when using this codepath? If the former then that's
> > pretty good, but
> > if the latter then it should probably be fixed.
> >
> 
> Short answer: muxing done by libwebpmux is different, so it's expected that
> it generates smaller WebP files.
> 
> Detailed answer:
> The native muxer is naive, and it always uses X offset and Y offset of 0
> for all frames. This means the full width x height of all frames are
> encoded.

> libwebpmux muxer is smart on the other hand: for example, it only encodes
> the part of the frame which has changed from previous frame.
> This and other optimizations result in smaller WebP files.

can you show some PSNR vs filesize information ?


> 
> Thanks,
> Urvang
> 
> 
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >

>  configure               |    5 ++
>  libavcodec/libwebpenc.c |   93 +++++++++++++++++++++++++++++++++++++++++++-----
>  libavformat/webpenc.c   |   44 ++++++++++++++++++++++

why are there changes to libavformat in a patch changing an encoder?


[...]
> index ee110de..0162eff 100644
> --- a/libavformat/webpenc.c
> +++ b/libavformat/webpenc.c
> @@ -22,12 +22,25 @@
>  #include "libavutil/intreadwrite.h"
>  #include "libavutil/opt.h"
>  #include "avformat.h"
> +#include "config.h"
>  #include "internal.h"
>  
> +#if CONFIG_LIBWEBP
> +#include <webp/encode.h>
> +#if HAVE_WEBP_MUX_H
> +#include <webp/mux.h>
> +#if (WEBP_MUX_ABI_VERSION >= 0x0105)
> +#define USE_WEBP_ANIMENCODER
> +#endif
> +#endif
> +#endif
> +
>  typedef struct WebpContext{
>      AVClass *class;
>      int frame_count;
> +#ifndef USE_WEBP_ANIMENCODER
>      AVPacket last_pkt;
> +#endif
>      int loop;
>  } WebpContext;
>  
> @@ -44,13 +57,40 @@ static int webp_write_header(AVFormatContext *s)
>          av_log(s, AV_LOG_ERROR, "Only WebP is supported\n");
>          return AVERROR(EINVAL);
>      }
> -    avpriv_set_pts_info(st, 24, 1, 1000);
>  
> +#ifndef USE_WEBP_ANIMENCODER
> +    avpriv_set_pts_info(st, 24, 1, 1000);
>      avio_write(s->pb, "RIFF\0\0\0\0WEBP", 12);
> +#endif
> +
> +    return 0;
> +}

this removes the timebase setting, that looks wrong

also please make sure -vcodec copy does if it works before the
patch, still work afterwards

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150423/ac406cec/attachment.asc>


More information about the ffmpeg-devel mailing list