[FFmpeg-devel] [PATCH 3/3] avformat/movenc: Add support for AVIF muxing

Vignesh Venkatasubramanian vigneshv at google.com
Tue May 3 00:34:56 EEST 2022


On Mon, May 2, 2022 at 10:28 AM James Zern
<jzern-at-google.com at ffmpeg.org> wrote:
>
> On Wed, Apr 13, 2022 at 1:40 PM Vignesh Venkatasubramanian
> <vigneshv-at-google.com at ffmpeg.org> wrote:
> >
> > Add an AVIF muxer by re-using the existing the mov/mp4 muxer.
> >
> > AVIF Specification: https://aomediacodec.github.io/av1-avif
> >
> > Sample usage for still image:
> > ffmpeg -i image.png -c:v libaom-av1 -avif-image 1 image.avif
> >
> > Sample usage for animated AVIF image:
> > ffmpeg -i video.mp4 animated.avif
> >
> > We can re-use any of the AV1 encoding options that will make
> > sense for image encoding (like bitrate, tiles, encoding speed,
> > etc).
> >
> > The files generated by this muxer has been verified to be valid
> > AVIF files by the following:
> > 1) Displays on Chrome (both still and animated images).
> > 2) Displays on Firefox (only still images, firefox does not support
> >    animated AVIF yet).
> > 3) Verified to be valid by Compliance Warden:
> >    https://github.com/gpac/ComplianceWarden
> >
> > Fixes the encoder/muxer part of Trac Ticket #7621
> >
> > Signed-off-by: Vignesh Venkatasubramanian <vigneshv at google.com>
> > ---
> >  configure                |   1 +
> >  libavformat/allformats.c |   1 +
> >  libavformat/movenc.c     | 337 ++++++++++++++++++++++++++++++++++++---
> >  libavformat/movenc.h     |   5 +
> >  4 files changed, 319 insertions(+), 25 deletions(-)
> >
>
> It would be good to have a Changelog entry after the ticket is fixed.
>

Acknowledged. Will do.

> > [...]
> > @@ -2823,7 +2848,10 @@ static int mov_write_hdlr_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra
> >
> >      if (track) {
> >          hdlr = (track->mode == MODE_MOV) ? "mhlr" : "\0\0\0\0";
> > -        if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) {
> > +        if (track->mode == MODE_AVIF) {
> > +            hdlr_type = "pict";
> > +            descr = "ffmpeg";
>
> Should this be PictureHandler or blank? What's written for heic?
>

Hmm, i used the string "ffmpeg" because libavif was writing "libavif"
[1]. But i think it makes sense to be consistent with the other types
here. I have updated the string to be "PictureHandler".

[1] https://github.com/AOMediaCodec/libavif/blob/45b6b1b88b54de6031c15b4f9dbee10f86244d1b/src/write.c#L456

> > [...]
> > +static int mov_write_ispe_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatContext *s)
> > +{
> > +    int64_t pos = avio_tell(pb);
> > +    avio_wb32(pb, 0); /* size */
> > +    ffio_wfourcc(pb, "ispe");
> > +    avio_wb32(pb, 0); /* Version & flags */
> > +    avio_wb32(pb, s->streams[0]->codecpar->width); /* image_width */
> > +    avio_wb32(pb, s->streams[0]->codecpar->height); /* image_height */
> > +    return update_size(pb, pos);
> > +}
> > +
> > +
>
> This extra line could be removed.

Removed.

>
> > [...]
> > +    /* AVIF output must have exactly one video stream */
> > +    if (mov->mode == MODE_AVIF) {
> > +        if (s->nb_streams > 1) {
> > +            av_log(s, AV_LOG_ERROR, "AVIF output requires exactly one stream\n");
> > +            return AVERROR(EINVAL);
> > +        }
> > +        if (s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) {
> > +            av_log(s, AV_LOG_ERROR, "AVIF output requires one video stream\n");
> > +            return AVERROR(EINVAL);
> > +        }
> > +    }
> > +
> > +
>
> This one too.

Removed.


> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".



--
Vignesh


More information about the ffmpeg-devel mailing list