Receiving RIFF chunks as `av_packet`s from `webpdec.c` in `webpenc.c` it wasn't doing proper animated frame detection/enumeration. Check for `ANIM`/`ANMF` chunks to see if the package is an animated WebP packet and for the `ANMF`/`ALPH`/`VP8 `/`VP8L` chunks if it's an actual frame.
Signed-off-by: Martin Reboredo <yakoy...@gmail.com> --- libavformat/webpenc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c index 9599fe7b85..50bee91910 100644 --- a/libavformat/webpenc.c +++ b/libavformat/webpenc.c @@ -55,13 +55,18 @@ static int is_animated_webp_packet(AVPacket *pkt) { int skip = 0; unsigned flags = 0; + int fourcc = AV_RL32(pkt->data); if (pkt->size < 4) return AVERROR_INVALIDDATA; - if (AV_RL32(pkt->data) == AV_RL32("RIFF")) + if (fourcc == AV_RL32("RIFF")) skip = 12; + else if (fourcc == AV_RL32("ANIM")) + return 1; + else if (fourcc == AV_RL32("ANMF")) + return 1; // Safe to do this as a valid WebP bitstream is >=30 bytes. - if (pkt->size < skip + 4) + if (pkt->size < skip + 4 && pkt->size != 12) return AVERROR_INVALIDDATA; if (AV_RL32(pkt->data + skip) == AV_RL32("VP8X")) { flags |= pkt->data[skip + 4 + 4]; @@ -143,6 +148,7 @@ static int flush(AVFormatContext *s, int trailer, int64_t pts) static int webp_write_packet(AVFormatContext *s, AVPacket *pkt) { WebpContext *w = s->priv_data; + int fourcc = AV_RL32(pkt->data); int ret; if (!pkt->size) @@ -161,7 +167,9 @@ static int webp_write_packet(AVFormatContext *s, AVPacket *pkt) return ret; av_packet_ref(&w->last_pkt, pkt); } - ++w->frame_count; + if (fourcc == AV_RL32("ANMF") || fourcc == AV_RL32("ALPH") || + fourcc == AV_RL32("VP8 ") || fourcc == AV_RL32("VP8L")) + ++w->frame_count; return 0; } -- 2.32.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".