吃透mp4格式系列——(五)
来源:互联网 发布:蒙泰打印机初始化端口 编辑:程序博客网 时间:2024/06/06 05:47
http://blog.csdn.net/pirateleo/article/details/7597892
MP4文件格式详解——元数据moov(二)tkhd box
元数据moov(二)tkhd box(ISO-14496-12)
Author:Pirate Leo
Email:codeevoship@gmail.com
ISO 14496 - 12 定义了一种封装媒体数据的基础文件格式,mp4、3gp、ismv等我们常见媒体封装格式都是以这种基础文件格式为基础衍生的。
如果从全局角度了解基础文件格式,请看我之前的博文《MP4文件格式详解——结构概述》。
本系列文档从MP4文件入手,对文件中重要的box进行解析。
<======================================================================>
本次继续解析moov box,关于moov的解析推荐从我上一篇博文《MP4文件格式详解——元数据moov(一)》看起。moov
√
container for all the metadata
mvhd
√
movie header, overall declarations
trak
√
container for an individual track or stream
tkhd
√
track header, overall information about the track
tref
track reference container
edts
edit list container
elst
an edit list
mdia
√
container for the media information in a track
mdhd
√
media header, overall information about the media
hdlr
√
handler, declares the media (handler) type
minf
√
media information container
vmhd
video media header, overall information (video track only)
smhd
sound media header, overall information (sound track only)
hmhd
hint media header, overall information (hint track only)
nmhd
Null media header, overall information (some tracks only)
dinf
√
data information box, container
dref
√
data reference box, declares source(s) of media data in track
stbl
√
sample table box, container for the time/space map
stsd
√
sample descriptions (codec types, initialization etc.)
stts
√
(decoding) time-to-sample
ctts
(composition) time to sample
stsc
√
sample-to-chunk, partial data-offset
information
stsz
sample sizes (framing)
stz2
compact sample sizes (framing)
stco
√
chunk offset, partial data-offset information
co64
64-bit chunk offset
stss
sync sample table (random access points)
stsh
shadow sync sample table
padb
sample padding bits
stdp
sample degradation priority
sdtp
independent and disposable samples
sbgp
sample-to-group
sgpd
sample group description
subs
sub-sample information
前面我们已经知道每个文件是由多个Track(轨道)组成的,每个Track都对应了自身trak box,其中存放了本track的元数据信息。
本次继续解析trak box的一系列子box:
1)tkhd box
类似我们moov中的mvhd box,但tkhd仅仅描述的单一Track的特性。
上图是实际媒体中的tkhd的数据:
0x5c是tkhd box长度,0x746b6864是“tkhd”的ASCII码。
0x00 00 00 0f是使用了Full box中的flag位(Full box 8bits version + 24bits flag,详见我第一篇日志),这里flag= 0xf,即1111b。
这4位从低到高分别代表:
Track_enabled: Indicates that the track is enabled. 若此位为0,则该track内容无需播放(比如我们用一些非线编软件<如Sony Vegas>做视频剪辑时,有些Track仅为我们参考与模仿用,在输出时将该Track关掉)。
Track_in_movie: Indicates that the track is used in the presentation.
Track_in_preview: Indicates that the track is used when previewing the presentation.
Track_in_poster: Indicates that the track is used in movie's poster.
/* -------------------------------------------------------------------------------------------------------*/
important:我们知道,MP4文件格式是ISO-14496-12基础文件格式的衍生品,14496-14中对-12协议进行了扩充与进一步定义。
重要的是该“14496-12 基础文件格式”协议如果认祖归宗,我们发现这种文件格式最初是由Apple公司的QuickTime媒体格式发展而来的。
即,mov格式发展出了“ISO 14496 - 12协议”,再由该协议衍生出了mp4,f4v,ismv,3gp等我们常见的媒体封装格式。
因此上述标志位的poster位,在14496-12中并没有见到描述,而在Apple的协议中却看到了准确定义。
详见 https://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap2/qtff2.html
/* -------------------------------------------------------------------------------------------------------*/
两个0xc5268eb6 是track的创建时间与最后修改时间;
紧随其后的0x00000002,代表track ID =2,Track ID是非0的,唯一的,不可重复使用的标识track的方式;
后面32bit全0是保留位;0x0009d97c是本track的时长,需要配合mvhd box中的timescale 计算实际的持续时间。
后续一些写死的字段不再分析,有些与mvhd重复,可以参见之前的文章。我们看两个关键字段:
layer,类似photoshop中图层的概念,数值小的在播放时更贴近用户(上层图层)。
alternate_group,track的备用分组ID,当该值为0时,意味着本track内容无备份;否则本track会可能会有零到多个备份track。当播放时相同group ID的track只选择一个进行播放。
- 吃透mp4格式系列——(五)
- 吃透mp4格式系列——(一)
- 吃透mp4格式系列——(二)
- 吃透mp4格式系列——(三)
- 吃透mp4格式系列——(四)
- 吃透mp4格式系列——(六)
- 吃透mp4格式系列——(七)
- 视频封装格式——MP4
- 视频封装格式——MP4
- mp4格式(转)
- MP4学习(一)MP4格式分析
- mp4格式(转帖加修改)
- mp4格式(转帖加修改)
- MP4格式基本概念——非常详细,神文
- mp4格式
- mp4格式
- Mp4格式
- 【流媒體】H264—MP4格式及在MP4文件中提取H264的SPS、PPS及码流(转)http://www.cnblogs.com/skyseraph/
- 吃透mp4格式系列——(四)
- 深入理解Java中的final关键字
- 我与网易云音乐 之 【弎】喜怒哀乐
- Retrofit框架设计-构建者+工厂模式高级应用
- ubuntu apt-get 速度慢 切换 阿里的源
- 吃透mp4格式系列——(五)
- 第838期机器学习日报(2017-01-03)
- 爬虫知识点(ajax异步加载,JavaScript 动态刷新,phantomjs + selenium模拟登陆)
- 第830期机器学习日报(2016-12-26)
- 第831期机器学习日报(2016-12-27)
- 第833期机器学习日报(2016-12-29)
- 第832期机器学习日报(2016-12-28)
- 第837期机器学习日报(2017-01-02)
- Glide真的可以显示gif且能控制结束