On Fri, 23 Aug 2013 07:33:15 +0200, Anton Khirnov <[email protected]> wrote:
> 
> On Thu, 22 Aug 2013 07:25:18 -0700, John Stebbins <[email protected]> 
> wrote:
> > QuickTime will play multiple audio tracks concurrently if this flag is
> > set for multiple audio tracks.  And if no subtitle track has this flag
> > set, QuickTime will show no subtitles in the subtitle menu.
> > ---
> >  libavformat/movenc.c | 58 
> > +++++++++++++++++++++++++++++++++++++++++++++++++++-
> >  libavformat/movenc.h |  1 +
> >  2 files changed, 58 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> > index 0c6b09d..8f69d64 100644
> > --- a/libavformat/movenc.c
> > +++ b/libavformat/movenc.c
> > @@ -1391,7 +1391,9 @@ static int mov_write_tkhd_tag(AVIOContext *pb, 
> > MOVTrack *track, AVStream *st)
> >      (version == 1) ? avio_wb32(pb, 104) : avio_wb32(pb, 92); /* size */
> >      ffio_wfourcc(pb, "tkhd");
> >      avio_w8(pb, version);
> > -    avio_wb24(pb, 0xf); /* flags (track enabled) */
> > +    avio_wb24(pb, (track->flags & MOV_TRACK_ENABLED) ?
> > +                  MOV_TKHD_FLAG_ENABLED | MOV_TKHD_FLAG_IN_MOVIE :
> > +                  MOV_TKHD_FLAG_IN_MOVIE);
> >      if (version == 1) {
> >          avio_wb64(pb, track->time);
> >          avio_wb64(pb, track->time);
> > @@ -3028,6 +3030,58 @@ static int mov_create_chapter_track(AVFormatContext 
> > *s, int tracknum)
> >      return 0;
> >  }
> >  
> > +/*
> > + * st->disposition controls the "enabled" flag in the tkhd tag.
> > + * QuickTime will not play a track if it is not enabled.  So make sure
> > + * that one track of each type (audio, video, subtitle) is enabled.
> > + *
> > + * Subtitles are special.  For audio and video, setting "enabled" also
> > + * makes the track "default" (i.e. it is rendered when played). For
> > + * subtitles, an "enabled" subtitle is not rendered by default, but
> > + * if no subtitle is enabled, the subtitle menu in QuickTime will be
> > + * empty!
> > + */
> > +static void enable_tracks(AVFormatContext *s)
> > +{
> > +    MOVMuxContext *mov = s->priv_data;
> > +    int i;
> > +    uint8_t enabled[AVMEDIA_TYPE_NB];
> > +    int first[AVMEDIA_TYPE_NB];
> > +
> > +    for (i = 0; i < AVMEDIA_TYPE_NB; i++) {
> > +        enabled[i] = 0;
> > +        first[i] = -1;
> > +    }
> > +
> > +    for (i = 0; i < s->nb_streams; i++) {
> > +        AVStream *st = s->streams[i];
> > +
> > +        if (st->codec->codec_type <= AVMEDIA_TYPE_UNKNOWN ||
> > +            st->codec->codec_type >= AVMEDIA_TYPE_NB)
> > +            continue;
> > +
> > +        if (first[st->codec->codec_type] < 0)
> > +            first[st->codec->codec_type] = i;
> > +        if (st->disposition & AV_DISPOSITION_DEFAULT) {
> > +            mov->tracks[i].flags |= MOV_TRACK_ENABLED;
> > +            enabled[st->codec->codec_type] = 1;
> > +        }
> > +    }
> > +
> > +    for (i = 0; i < AVMEDIA_TYPE_NB; i++) {
> > +        switch (i) {
> > +        case AVMEDIA_TYPE_VIDEO:
> > +        case AVMEDIA_TYPE_AUDIO:
> > +        case AVMEDIA_TYPE_SUBTITLE:
> > +            if (!enabled[i] && first[i] >= 0)
> > +                mov->tracks[first[i]].flags |= MOV_TRACK_ENABLED;
> > +            break;
> > +        default:
> > +            break;
> 
> The default part looks pointless.
> 
> Otherwise the patchset looks good.

Pushed without the default and with FATE updates

-- 
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to