【多媒体封装格式详解】---MP4【2】
来源:互联网 发布:淘宝怎么搜vr资源 编辑:程序博客网 时间:2024/06/05 05:25
1.File Type Box
Box Type: `ftyp’
这种box一般情况下都会出现在mp4文件的开头,它可以作为mp4容器格式的可表示信息。就像flv头‘F’ 'L' 'V' 3字节,MKV头部的1A 45 DF A3 、ASF_Header_Object 可以作为ASF容器格式的可辨识信息一样。
ftyp 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}
2.Movie Box
moov 这个box 里面包含了很多个子box,就像上篇那个图上标的。一般情况下moov 会紧跟着 ftyp。moov里面包含着mp4文件中的metedata。音视频相关的基础信息。让我们看看moov 里面都含有哪些重要的box。
2.1 Movie Header Box
aligned(8) class MovieHeaderBox extends FullBox(‘mvhd’, 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;}template int(32) rate = 0x00010000; // typically 1.0template int(16) volume = 0x0100; // typically, full volumeconst bit(16) reserved = 0;const unsigned int(32)[2] reserved = 0;template int(32)[9] matrix ={ 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 };// Unity matrixbit(32)[6] pre_defined = 0;unsigned int(32) next_track_ID;}
Field
Type
Comment
box size
4
box大小
box type
4
box类型
version
1
box版本,0或1,一般为0。
flags
3
flags
creation time
4
创建时间(相对于UTC时间1904-01-01零点的秒数)
modification time
4
修改时间
time scale
4
文件媒体在1秒时间内的刻度值,可以理解为1秒长度的时间单元数
一般情况下视频的 都是90000
duration
4
该track的时间长度,用duration和time scale值可以计算track时长,比如audio track的time scale = 8000, duration = 560128,时长为
70.016,video track的time scale = 600, duration = 42000,时长为70
rate
4
推荐播放速率,高16位和低16位分别为小数点整数部分和小数部分,即[16.16] 格式,该值为1.0(0x00010000)表示正常前向播放
volume
2
与rate类似,[8.8] 格式,1.0(0x0100)表示最大音量
reserved
10
保留位
matrix
36
视频变换矩阵
pre-defined
24
next track id
4
下一个track使用的id号
所以通过解析这部分内容可以或者duration、rate等主要信息。举个例子:
2.2 Track Box
2.2.1 Track Header Box
aligned(8) class TrackHeaderBoxextends FullBox(‘tkhd’, version, flags){if (version==1) {unsigned int(64) creation_time;unsigned int(64) modification_time;unsigned int(32) track_ID;const unsigned int(32) reserved = 0;unsigned int(64) duration;} else { // version==0unsigned int(32) creation_time;unsigned int(32) modification_time;unsigned int(32) track_ID;const unsigned int(32) reserved = 0;unsigned int(32) duration;}const unsigned int(32)[2] reserved = 0;template int(16) layer = 0;template int(16) alternate_group = 0;template int(16) volume = {if track_is_audio 0x0100 else 0};const unsigned int(16) reserved = 0;template int(32)[9] matrix={ 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 };// unity matrixunsigned int(32) width;unsigned int(32) height;}
Field
Type
Comment
box size
4
box大小
box type
4
box类型
version
1
box版本,0或1,一般为0。
flags
3
按位或操作结果值,预定义如下:
0x000001 track_enabled,否则该track不被播放;
0x000002 track_in_movie,表示该track在播放中被引用;
0x000004 track_in_preview,表示该track在预览时被引用。
一般该值为7,如果一个媒体所有track均未设置track_in_movie和track_in_preview,将被理解为所有track均设置了这两项;对于hint track,该值为0
track id
4
id号,不能重复且不能为0
reserved
4
保留位
duration
4
track的时间长度
reserved
8
保留位
layer
2
视频层,默认为0,值小的在上层
alternate group
2
track分组信息,默认为0表示该track未与其他track有群组关系
volume
2
[8.8] 格式,如果为音频track,1.0(0x0100)表示最大音量;否则为0
reserved
2
保留位
matrix
36
视频变换矩阵
width
4
宽
height
4
高,均为 [16.16] 格式值,与sample描述中的实际画面大小比值,用于播放时的展示宽高
未完待续... 下一篇 Media Box
- 【多媒体封装格式详解】---MP4【2】
- 【多媒体封装格式详解】---MP4【2】
- 【多媒体封装格式详解】---MP4
- 【多媒体封装格式详解】---MP4【1】
- 【多媒体封装格式详解】---MP4【3】
- 【多媒体封装格式详解】---MP4【4】
- 多媒体封装格式详解(01) MP4
- 【多媒体封装格式详解】---MP4【1】
- 【多媒体封装格式详解】---MP4【3】
- 【多媒体封装格式详解】---MP4【4】
- MP4封装格式详解
- MP4封装格式详解
- MP4封装格式详解
- 【多媒体封装格式详解】---MKV【2】
- 【多媒体封装格式详解】---MKV【2】
- MP4封装格式详解1
- MP4文件封装格式详解
- 【多媒体封装格式详解】---FLV
- 十步优化SQL Server中的数据访问
- Windows下编译测试BM3D算法效果
- 管理员如何执行WCM内容内在Portal系统之间进行内容与配置迁移
- Zend Studio中导入Aptana配色方案
- vsftpd匿名登录的设置方法
- 【多媒体封装格式详解】---MP4【2】
- destoon代码从头到尾捋一遍
- Android之最简单的ImageView加边框方法
- u-boot 使用
- 图形报表部署在Linux下出现乱码解决办法
- NTCPMSG 开源高性能TCP消息发送组件
- Linux常用命令02 cd
- [FreeBSD]_[Shell编程]
- Android百度地图基础实现(标记+GPS)