Ticket #468: 0002-movenc-set-alternative-group-for-audio-and-subtitles.patch

File 0002-movenc-set-alternative-group-for-audio-and-subtitles.patch, 2.9 KB (added by michael, 5 years ago)

Untested patch

  • libavformat/movenc.c

    From 9024befc30159e036b1eaeb6a8aaabbe8159f3d0 Mon Sep 17 00:00:00 2001
    From: Michael Niedermayer <michaelni@gmx.at>
    Date: Fri, 16 Sep 2011 02:41:27 +0200
    Subject: [PATCH 2/2] movenc: set alternative group for audio and subtitles
    
    Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
    ---
     libavformat/movenc.c |   13 +++++++++++--
     libavformat/movenc.h |    2 ++
     2 files changed, 13 insertions(+), 2 deletions(-)
    
    diff --git a/libavformat/movenc.c b/libavformat/movenc.c
    index b1dafdb..0a741de 100644
    a b static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st) 
    12111211    (version == 1) ? avio_wb32(pb, 104) : avio_wb32(pb, 92); /* size */ 
    12121212    ffio_wfourcc(pb, "tkhd"); 
    12131213    avio_w8(pb, version); 
    1214     avio_wb24(pb, 0xf); /* flags (track enabled) */ 
     1214    avio_wb24(pb, track->secondary ? 0x2 : 0xf); /* flags (first track enabled) */ 
    12151215    if (version == 1) { 
    12161216        avio_wb64(pb, track->time); 
    12171217        avio_wb64(pb, track->time); 
    static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st) 
    12251225 
    12261226    avio_wb32(pb, 0); /* reserved */ 
    12271227    avio_wb32(pb, 0); /* reserved */ 
    1228     avio_wb32(pb, 0x0); /* reserved (Layer & Alternate group) */ 
     1228    avio_wb32(pb, track->alternative_group); /* reserved (Layer & Alternate group) */ 
    12291229    /* Volume, only for audio */ 
    12301230    if(track->enc->codec_type == AVMEDIA_TYPE_AUDIO) 
    12311231        avio_wb16(pb, 0x0100); 
    static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov, 
    18071807{ 
    18081808    int i; 
    18091809    int64_t pos = avio_tell(pb); 
     1810    int not_first[AVMEDIA_TYPE_NB]={0}; 
    18101811    avio_wb32(pb, 0); /* size placeholder*/ 
    18111812    ffio_wfourcc(pb, "moov"); 
    18121813 
    static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov, 
    18341835    //mov_write_iods_tag(pb, mov); 
    18351836    for (i=0; i<mov->nb_streams; i++) { 
    18361837        if(mov->tracks[i].entry > 0) { 
     1838            if(i < s->nb_streams){ 
     1839                int codec_type= s->streams[i]->codec->codec_type; 
     1840                if(codec_type==AVMEDIA_TYPE_AUDIO || codec_type==AVMEDIA_TYPE_SUBTITLE){ 
     1841                    mov->tracks[i].alternative_group= 1 + (codec_type==AVMEDIA_TYPE_SUBTITLE); 
     1842                    mov->tracks[i].secondary= not_first[codec_type]; 
     1843                    not_first[codec_type]= 1; 
     1844                } 
     1845            } 
    18371846            mov_write_trak_tag(pb, &(mov->tracks[i]), i < s->nb_streams ? s->streams[i] : NULL); 
    18381847        } 
    18391848    } 
  • libavformat/movenc.h

    diff --git a/libavformat/movenc.h b/libavformat/movenc.h
    index 610683f..4676983 100644
    a b typedef struct MOVIndex { 
    7878#define MOV_TRACK_STPS         0x0002 
    7979    uint32_t    flags; 
    8080    int         language; 
     81    int         alternative_group; 
     82    int         secondary; 
    8183    int         trackID; 
    8284    int         tag; ///< stsd fourcc 
    8385    AVCodecContext *enc;