【多媒体封装格式详解】---MP4【3】
aligned(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==0unsigned 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 codeunsigned int(16) pre_defined = 0;}
Field
Type
Comment
box size
4
box大小
box type
4
box类型
version
1
box版本,0或1,一般为0。
creation time
4
创建时间(相对于UTC时间1904-01-01零点的秒数)
modification time
4
修改时间
time scale
4
文件媒体在1秒时间内的刻度值,可以理解为1秒长度的时间单元数
一般情况下视频的 都是90000
duration
4
该track的时间长度
language
2
媒体语言码
pre-defined
2
aligned(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;}
Field
Type
Comment
box size
4
box大小
box type
4
box类型
version
1
box版本,0或1,一般为0。
flags
3
pre-defined
4
handler_type
4
‘vide’ Video track
‘soun’ Audio track
‘hint’ Hint track
reserved
12
0
name
string
字符串 track type name
例子
00 00 00 2168 64 6C 7200 00 00 00 00 00 00 00 ; ...!hdlr........
76 69 64 65 00 00 00 00 00 00 00 00 00 00 00 00 ; vide............
00上面的例子 可知track 的类型是 ‘vide’ 这是个video trackField
Type
Comment
box size
4
box大小
box type
4
box类型
version
1
box版本,0或1,一般为0。
flags3
flags
graphicsmode
2
specifies a composition mode for this video track, from the following enumerated set,
which may be extended by derived specifications:
copy = 0 copy over the existing image
opcolor
2*3
is a set of 3 colour values (red, green, blue) available for use by graphics modes
例子:00 00 00 14 76 6D 68 640000 00 0100 00 00 00 ; ....vmhd........
00 00 00 00 ; ....
Sound Media Header Box(smhd)Field
Type
Comment
box size
4
box大小
box type
4
box类型
version
1
box版本,0或1,一般为0。
flags
3
flags
balance
2
立体声平衡,[8.8]格式值,一般为0,-1.0表示全部左声道,1.0表示全部右声道
reserved
2
0
例子:00 00 00 10 73 6D 68 64 00 00 00 0000 0000 00; ....smhd........
Hint Media Header Box(hmhd)aligned(8) class DataEntryUrlBox (bit(24) flags)extends FullBox(‘url ’, version = 0, flags) {string location;}aligned(8) class DataEntryUrnBox (bit(24) flags)extends FullBox(‘urn ’, version = 0, flags) {string name;string location;}aligned(8) class DataReferenceBoxextends FullBox(‘dref’, version = 0, 0) {unsigned int(32) entry_count;for (i=1; i ? entry_count; i++) {DataEntryBox(entry_version, entry_flags) data_entry;}}
未完待续。。。。。接下来要把里面的真实数据流搞出来。