MP4 Box Information Example Analysis 1

Source: Internet
Author: User
Tags reserved

Download the relevant documentation from here:
http://standards.iso.org/ittf/PubliclyAvailableStandards/index.html One, box overall view

The following image is excerpted from: http://www.cnblogs.com/haibindev/archive/2011/10/17/2214518.html

second, box definition

Excerpt from specification: iso_iec_14496-12_2012

This article describes: 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, Box aligned (8) class box (unsigned int () boxtype, optional unsigned int (8) [+] extended_type) {unsigned int (32)
    Size
    unsigned int (+) type = Boxtype;
    if (size==1) {unsigned int () largesize; } else if (size==0) {//box extends to end of file} if (boxtype== ' uuid ') {unsigned int (8) [+] Usertype
    = Extended_type; }} aligned (8) class Fullbox (unsigned int (boxtype), unsigned int (8) v, bit (+) f) extends Box (boxtype) {unsigned
    Int (8) version = V;
Bit () flags = f;
    } 2, Ftyp box aligned (8) Class Filetypebox extends Box (' Ftyp ') {unsigned int (+) Major_brand;
    unsigned int (+) minor_version;
unsigned int (+) compatible_brands[];
}/* Each brand was a printable four-character code, registered with ISO, that identifies a precise specification. Major_brand–is a brand identifier Minor_version–is an informative integer for the minor version of the major brand COM Patible_brands–is a list, to the end of the box, of brands */3, Moov box//-------------movie Structure--------------------////----movie box--////definition box Typ  E: ' Moov ' container:file mandatory:yes quantity:exactly one//syntax aligned (8) class MovieBox extends Box (' Moov ') {} 3.1 MVHD box//---Movie Header box---////definition box Type: ' Mvhd ' container:movie box (' Moov ') Mandatory:yes Quantity:exac tly one//syntax aligned (8) class Movieheaderbox extends Fullbox (' mvhd ', version, 0) {if (version==1) {Unsi
        gned int (creation_time);
        unsigned int (modification_time);
        unsigned int (+) timescale;
    unsigned int (duration);
        } else {//version==0 unsigned int (+) Creation_time;
        unsigned int (+) Modification_time;
        unsigned int (+) timescale;
    unsigned int (+) duration; } template int (+) rate = 0x00010000;
    typically 1.0 template int (volume) = 0x0100;
    Typically, full volume const bit (reserved) = 0; const unsigned INT (32) [2] reserved = 0;
    template int (+) [9] matrix = {0x00010000,0,0,0,0x00010000,0,0,0,0x40000000};
    Unity Matrix bit (+) [6] pre_defined = 0;
unsigned int (+) next_track_id; } 3.2 Track box//----Track box--//8.3.1.1 track box//definition box Type: ' Trak ' container:movie box (' Moov ') mandator Y:yes Quantity:one or more 8.3.1.2//syntax aligned (8) Class Trackbox extends Box (' Trak ') {} 3.2.1 Track header box//-  ----8.3.2.1 track Header box--////definition box Type: ' Tkhd ' container:track box (' Trak ') Mandatory:yes quantity:exactly
        One//8.3.2.2 Syntax aligned (8) class Trackheaderbox extends Fullbox (' TKHD ', version, flags) {if (version==1) {
        unsigned int (creation_time);
        unsigned int (modification_time);
        unsigned int (+) track_id;
        const unsigned int (+) reserved = 0;
    unsigned int (duration);
        } else {//version==0 unsigned int (+) Creation_time;
        unsigned int (+) Modification_time; Unsigned Int (+) track_id;
        const unsigned int (+) reserved = 0;
    unsigned int (+) duration;
    } const unsigned int (+) [2] reserved = 0;
    template int (+) layer = 0;
    template int (alternate_group) = 0;
    template int (volume) = {if Track_is_audio 0x0100 else 0};
    const unsigned int (reserved) = 0;
    template int (+) [9] matrix= {0x00010000,0,0,0,0x00010000,0,0,0,0x40000000};
    Unity Matrix unsigned int (+) width;
unsigned int (+) height; }//--------8.3.3 track Reference box-----////8.3.3.1 Definition box Type: ' Tref ' container:track Box (' Trak ') Mandatory: No Quantity:zero or one//8.3.3.2 Syntax aligned (8) class Trackreferencebox extends Box (' Tref ') {} aligned (8) class Trac


Kreferencetypebox (unsigned int (+) reference_type) extends Box (reference_type) {unsigned int (+) track_ids[];} ---------------------8.4 Track Media Structure-------------////--8.4.1 media Box--////8.4.1.1 Definition Box Type: ' m Dia ' Container:tracK Box (' Trak ') mandatory:yes quantity:exactly one//8.4.1.2 Syntax aligned (8) class Mediabox extends Box (' Mdia ') {}//- -8.4.2 Media Header box--////8.4.2.1 Definition box Type: ' Mdhd ' container:media box (' Mdia ') Mandatory:yes Quantity:exac
        tly one//8.4.2.2 Syntax aligned (8) class Mediaheaderbox extends Fullbox (' MDHD ', version, 0) {if (version==1) {
        unsigned int (creation_time);
        unsigned int (modification_time);
        unsigned int (+) timescale;
    unsigned int (duration);
        } else {//version==0 unsigned int (+) Creation_time;
        unsigned int (+) Modification_time;
        unsigned int (+) timescale;
    unsigned int (+) duration;
    } bit (1) pad = 0;   unsigned int (5) [3] language;
iso-639-2/t Language Code unsigned int (+) pre_defined = 0; }//---------------8.4.3 Handler Reference box-------////8.4.3.1 Definition box Type: ' Hdlr ' container:media box (' Mdia ') or meta Box (' meta ') Mandatory:yes Quantity:exactly one//8.4.3.2 Syntax aligned (8) class Handlerbox extends Fullbox (' hdlr ', Version = 0, 0) {unsigned int (
    pre_defined = 0;
    unsigned int (+) Handler_type;
    const unsigned int (+) [3] reserved = 0;
String name; }//8.4.3.3 Semantics/* version is an integer that specifies the version of this box handler_type when present in a Medi A box, is an integer containing one of the following values, or a value from a derived specification: ' vide ' Video track '  Soun ' Audio track ' hint ' hint track ' meta ' Timed Metadata track ' AUXV ' auxiliary Video track handler_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's merely being used to hold resources. Name is a null-terminated string of UTF-8 characters which gives a human-readable name for the track type (for debugging a
ND inspection purposes). *///----8.4.4 Media information Box----////8.4.4.1 Definition box Type: ' Minf ' container:media box (' Mdia ') mandatory:yes quantity:exactly one//8.4.4.2 Syntax Aligned (8) class Mediainformationbox extends Box (' Minf ') {}//-----8.4.5 Media Information Header Boxes---////8.4.5. 1 Definition Box Types: ' Vmhd ', ' smhd ', ' hmhd ', ' NMHD ' Container:media information Box (' Minf ') Mandatory:yes Quantity:exac tly one specific media header shall be present///the following are different specific types://8.4.5.2 Video Media header Box aligned (8) class Videomedia
    Headerbox extends Fullbox (' VMHD ', Version = 0, 1) {Template unsigned int (+) Graphicsmode = 0;
Copy, see below template unsigned int (+) [3] Opcolor = {0, 0, 0}; }//8.4.5.3 Sound Media Header Box aligned (8) class Soundmediaheaderbox extends Fullbox (' SMHD ', Version = 0, 0) {tem
    plate int (balance) = 0;
const unsigned int (reserved) = 0; }//8.4.5.4 Hint Media Header Box aligned (8) class Hintmediaheaderbox extends Fullbox (' HMHD ', Version = 0, 0) {Unsig Ned Int (maxpdusize);
    unsigned int (avgpdusize);
    unsigned int (+) maxbitrate;
    unsigned int (+) avgbitrate;
unsigned int (+) reserved = 0;  }//8.4.5.5 Null Media Header Box Streams other than visual and audio (e.g., timed metadata Streams) could use a null media

Header Box, as defined here.
 Aligned (8) class Nullmediaheaderbox extends Fullbox (' NMHD ', Version = 0, flags) {}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.