本文主要是介绍IOS 基础媒体文件格式语法描述和语意(MP4文件格式分析实例),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Boxes start with a header which gives both size and type.
在最前面Box 包含 size和type,size和type都是占4个字节。
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).
允许根据需要,将size 简化或者扩展,同样的,对于type 也可以根据需要进行简化或者扩展。
简化,即使用32位的 size 和type. 扩展,即使用64位的size 和type.
The standard boxes all use compact types (32-bit) and most boxes will use the compact (32-bit) size.
标准的box 使用简化的type,即32位的,大多数box一般也都使用简化的 32位的 size。
Typicallyonly the Media Data Box(es) need the 64-bit size.
但是 Media Data Box 需要使用64位的size.
The size is the entire size of the box, including the size and type header, fields, and all contained boxes.
size指的是整个Box的大小,包括头部的 size和type 的大小,以及后面的值和所有的包含的其他box .
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;
}}
二、扩展对象
扩展对象继承了 Box,并在此基础上增加了 version和 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;
}
1、File Type Box
aligned(8) class FileTypeBoxextends Box(‘ftyp’) {unsigned int(32) major_brand;unsigned int(32) minor_version;unsigned int(32) compatible_brands[]; // to end of the box
}
计算一下FileTypeBox的大小:
size占32位,4个字节;
type占32位,4个字节;
major_brand占32位,4个字节;
minor_version占32位,4个字节;
compatible_brands 每个brand占32位,4个字节;
2、Free Space Box
aligned(8) class FreeSpaceBox extends Box('free') {
unsigned int(8) data[];
}
计算一下Free Space Box的大小:
size占32位,4个字节;
type占32位,4个字节;
每个 data 占8位,1个字节;
3、Media Data Box
aligned(8) class MediaDataBox extends Box(‘mdat’) {
bit(8) data[];
}
计算一下Media Data Box的大小:
size占32位,4个字节;
type占32位,4个字节;
每个 data 占8位,1个字节;
aligned(8) class MovieBox extends Box(‘moov’){
}
计算一下Movie Box 的大小:
size占32位,4个字节;
type占32位,4个字节;
boxtype==‘uuid’
这篇关于IOS 基础媒体文件格式语法描述和语意(MP4文件格式分析实例)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!