mp4 box信息实例分析 1

来源:互联网 发布:中国最帅的程序员 编辑:程序博客网 时间:2024/05/17 14:27

相关文档从这里下载:
http://standards.iso.org/ittf/PubliclyAvailableStandards/index.html

一、BOX总体视图

以下图片摘自:http://www.cnblogs.com/haibindev/archive/2011/10/17/2214518.html

这里写图片描述

这里写图片描述

这里写图片描述

二、box定义

摘自规范:ISO_IEC_14496-12_2012

本文介绍:

  • ftyp
  • moov
    • mvhd
    • trak
      • tkhd
      • tref
      • mdia
        • mdhd
        • hdlr
        • minf
          • vmhd
          • smhd
          • hmhd
          • nmhd
  • -

moov,mvhd,trak,tkhd,tref,mdia,mdhd,hdlr,minf,vmhd,smhd,hmhd,nmhd

1、BOXaligned(8) class Box (unsigned int(32) boxtype,optional unsigned int(8)[16] extended_type) {    unsigned int(32) size;    unsigned int(32) type = boxtype;    if (size==1) {    unsigned int(64) largesize;    } else if (size==0) {    // box extends to end of file    }    if (boxtype==‘uuid’) {    unsigned int(8)[16] usertype = extended_type;    }}aligned(8) class FullBox(unsigned int(32) boxtype, unsigned int(8) v, bit(24) f) extends Box(boxtype) {    unsigned int(8)    version = v;    bit(24)    flags = f;}2、ftyp BOXaligned(8) class FileTypeBox extends Box(‘ftyp’) {    unsigned int(32) major_brand;    unsigned int(32) minor_version;    unsigned int(32) compatible_brands[];}/*Each brand is a printable four-character code, registered with ISO, that identifies a precise specification.major_brand – is a brand identifierminor_version – is an informative integer for the minor version of the major brandcompatible_brands – is a list, to the end of the box, of brands*/3、moov box//------------- Movie Structure --------------------////----Movie Box--////DefinitionBox Type:‘moov’Container:FileMandatory:YesQuantity:Exactly one//Syntaxaligned(8) class MovieBox extends Box(‘moov’){}3.1 mvhd box//---Movie Header Box---////DefinitionBox Type:‘mvhd’Container:Movie Box (‘moov’)Mandatory:YesQuantity:Exactly one//Syntaxaligned(8) class MovieHeaderBox extends FullBox(‘mvhd’, version, 0) {    if (version==1) {        unsigned int(64) creation_time;        unsigned int(64) modification_time;        unsigned int(32) timescale;        unsigned int(64) duration;    } else { // version==0        unsigned int(32) creation_time;        unsigned int(32) modification_time;        unsigned int(32) timescale;        unsigned int(32) duration;    }    template int(32) rate = 0x00010000; // typically 1.0    template int(16) volume = 0x0100;    // typically, full volume    const bit(16) reserved = 0;    const unsigned int(32)[2] reserved = 0;    template int(32)[9] matrix =    { 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 };    // Unity matrix    bit(32)[6] pre_defined = 0;    unsigned int(32) next_track_ID;}3.2 track box//----Track Box --//8.3.1.1 Track Box//DefinitionBox Type:‘trak’Container:Movie Box (‘moov’)Mandatory:YesQuantity:One or more8.3.1.2//Syntaxaligned(8) class TrackBox extends Box(‘trak’) {}3.2.1 track header box//-----8.3.2.1 Track Header Box--////DefinitionBox Type:‘tkhd’Container:Track Box (‘trak’)Mandatory:YesQuantity:Exactly one//8.3.2.2 Syntaxaligned(8) class TrackHeaderBoxextends FullBox(‘tkhd’, version, flags){    if (version==1) {        unsigned int(64) creation_time;        unsigned int(64) modification_time;        unsigned int(32) track_ID;        const unsigned int(32) reserved = 0;        unsigned int(64) duration;    } else { // version==0        unsigned int(32) creation_time;        unsigned int(32) modification_time;        unsigned int(32) track_ID;        const unsigned int(32) reserved = 0;        unsigned int(32) duration;    }    const unsigned int(32)[2] reserved = 0;    template int(16) layer = 0;    template int(16) alternate_group = 0;    template int(16) volume = {if track_is_audio 0x0100 else 0};    const unsigned int(16) reserved = 0;    template int(32)[9] matrix=    { 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 };    // unity matrix    unsigned int(32) width;    unsigned int(32) height;}//--------8.3.3 Track Reference Box-----////8.3.3.1 DefinitionBox Type:`tref’Container:Track Box (‘trak’)Mandatory:NoQuantity:Zero or one//8.3.3.2 Syntaxaligned(8) class TrackReferenceBox extends Box(‘tref’) {}aligned(8) class TrackReferenceTypeBox (unsigned int(32) reference_type) extendsBox(reference_type) {    unsigned int(32) track_IDs[];}//---------------------8.4 Track Media Structure-------------////--8.4.1 Media Box --////8.4.1.1 DefinitionBox Type:‘mdia’Container:Track Box (‘trak’)Mandatory:YesQuantity:Exactly one//8.4.1.2 Syntaxaligned(8) class MediaBox extends Box(‘mdia’) {}//--8.4.2 Media Header Box --////8.4.2.1 DefinitionBox Type:‘mdhd’Container:Media Box (‘mdia’)Mandatory:YesQuantity:Exactly one//8.4.2.2 Syntaxaligned(8) class MediaHeaderBox extends FullBox(‘mdhd’, version, 0) {    if (version==1) {        unsigned int(64) creation_time;        unsigned int(64) modification_time;        unsigned int(32) timescale;        unsigned int(64) duration;    } else { // version==0        unsigned int(32) creation_time;        unsigned int(32) modification_time;        unsigned int(32) timescale;        unsigned int(32) duration;    }    bit(1)    pad = 0;    unsigned int(5)[3]    language;   // ISO-639-2/T language code    unsigned int(16) pre_defined = 0;}//---------------8.4.3 Handler Reference Box -------////8.4.3.1 DefinitionBox Type:‘hdlr’Container:Media Box (‘mdia’) or Meta Box (‘meta’)Mandatory:YesQuantity:Exactly one//8.4.3.2 Syntaxaligned(8) class HandlerBox extends FullBox(‘hdlr’, version = 0, 0) {    unsigned int(32) pre_defined = 0;    unsigned int(32) handler_type;    const unsigned int(32)[3] reserved = 0;    string  name;}//8.4.3.3 Semantics/*version is an integer that specifies the version of this boxhandler_type when present in a media box, is an integer containing one of the following values, or avalue from a derived specification:‘vide’ Video track‘soun’ Audio track‘hint’ Hint track‘meta’ Timed Metadata track‘auxv’ Auxiliary Video trackhandler_type when present in a meta box, contains an appropriate value to indicate the format of the meta box contents. The value ‘null’ can be used in the primary meta box to indicate that it ismerely being used to hold resources.name is a null-terminated string in UTF-8 characters which gives a human-readable name for the track type (for debugging and inspection purposes).*///----8.4.4 Media Information Box----////8.4.4.1 DefinitionBox Type:‘minf’Container:Media Box (‘mdia’)Mandatory:YesQuantity:Exactly one//8.4.4.2 Syntaxaligned(8) class MediaInformationBox extends Box(‘minf’) {}//-----8.4.5 Media Information Header Boxes ---////8.4.5.1 DefinitionBox Types:‘vmhd’, ‘smhd’, ’hmhd’, ‘nmhd’Container:Media Information Box (‘minf’)Mandatory:YesQuantity:Exactly one specific media header shall be present//下面是不同的具体类型://8.4.5.2 Video Media Header Boxaligned(8) class VideoMediaHeaderBox extends FullBox(‘vmhd’, version = 0, 1) {    template unsigned int(16) graphicsmode = 0;    // copy, see below    template unsigned int(16)[3] opcolor = {0, 0, 0};}//8.4.5.3 Sound Media Header Boxaligned(8) class SoundMediaHeaderBox extends FullBox(‘smhd’, version = 0, 0) {    template int(16) balance = 0;    const unsigned int(16) reserved = 0;}//8.4.5.4 Hint Media Header Boxaligned(8) class HintMediaHeaderBox extends FullBox(‘hmhd’, version = 0, 0) {    unsigned int(16) maxPDUsize;    unsigned int(16) avgPDUsize;    unsigned int(32) maxbitrate;    unsigned int(32) avgbitrate;    unsigned int(32) reserved = 0;}//8.4.5.5 Null Media Header BoxStreams other than visual and audio (e.g., timed metadata streams) may use a null Media Header Box, as defined here.aligned(8) class NullMediaHeaderBox extends FullBox(’nmhd’, version = 0, flags) {}

这里写图片描述

这里写图片描述

0 0
原创粉丝点击