2.2.2 Media Box
2.2.2.1 Media Header Box
Box Type: ‘mdhd’
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==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;
}
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 |
2.2.2.2 Handler Reference Box
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............
002.2.2.3 Media Information Box
2.2.2.3.1 Media Information Header Boxes
aligned(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};
}
Field |
Type |
Comment |
box size |
4 |
box大小 |
box type |
4 |
box类型 |
version |
1 |
box版本,0或1,一般为0。 |
flags | 3 |
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 01 00 00 00 00 ; ....vmhd........
00 00 00 00 ; ....
Sound Media Header Box(smhd)
aligned(8) class SoundMediaHeaderBox
extends FullBox(‘smhd’, version = 0, 0) {
template int(16) balance = 0;
const unsigned int(16) reserved = 0;
}
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 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;
}
2.2.2.3.2 Data Information Box
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 DataReferenceBox
extends FullBox(‘dref’, version = 0, 0) {
unsigned int(32) entry_count;
for (i=1; i • entry_count; i++) {
DataEntryBox(entry_version, entry_flags) data_entry;
}
}