IOS basic media file format syntax description and semantics (MP4 File Format analysis instance)

Source: Internet
Author: User
Tags compact
I. Basic Object box

Boxes start with a header which gives both size and type.

The front box contains the size and type, and both the size and type occupy four bytes.


The header permits compact or extended size (32or 64 bits) and compact or extended types (32 bits or full universal unique identifiers, I. e. uuids ).

The size can be simplified or expanded as needed. Similarly, the type can be simplified or expanded as needed.

Simplified: 32-bit size and type. extension, that is, 64-bit size and type.


The standard boxes all use compact types (32-bit) and most boxes will use the Compact (32-bit) size.

Standard boxes use a simplified type, that is, 32-bit. Most boxes generally use a simplified 32-bit size.


Typicallyonly the media data box (es) need the 64-bit size.

However, the 64-bit size is required for the media data box.


The size is the entire size of the box, including the size and type header, fields, and all contained boxes.

Size refers to the size of the entire box, including the size and type of the header, as well as the following values and all other boxes.

 aligned(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;}}  

Ii. Extension object

The extended object inherits box and adds version and flages.

 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;}  

3. Build File objects

1. File Type box

 aligned(8) class FileTypeBox    extends Box(‘ftyp’) {    unsigned int(32) major_brand;    unsigned int(32) minor_version;    unsigned int(32) compatible_brands[]; // to end of the box}  

Calculate the filetypebox size:

Size occupies 32 bits, 4 bytes;

Type occupies 32 bits, 4 bytes;

Major_brand occupies 32 bits, 4 bytes;

Minor_version occupies 32 bits, 4 bytes;

Compatible_brands each brand occupies 32 bits, 4 bytes;



2. Free Space box

 aligned(8) class FreeSpaceBox extends Box('free') { 
    unsigned int(8) data[];} 

Calculate the free space box size:

Size occupies 32 bits, 4 bytes;

Type occupies 32 bits, 4 bytes;

Each data occupies 8 bits and 1 byte;

3. Media Data box


Aligned (8) Class mediadatabox extends box ('mdat '){

Bit (8) data [];

}

Calculate the size of the media data box:

Size occupies 32 bits, 4 bytes;

Type occupies 32 bits, 4 bytes;

Each data occupies 8 bits and 1 byte;

4. Movie box

Aligned (8) Class moviebox extends box ('moov '){


}

Calculate the movie box size:

Size occupies 32 bits, 4 bytes;

Type occupies 32 bits, 4 bytes;


5. UUID
The above analysis uses an MP4 file to analyze the size, type, and location of the top-level box in the MP4 file format.


UUID. According to the definition of the basic object box, if

boxtype==‘uuid’
The extension type must contain 16 bytes after the type. The extension type is followed by data.


The sub-box in the top-level box has not been described yet, and will continue in the next article.
<EOF>
Related Article

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.