介绍
mp4⽂件格式⼜被称为MPEG-4 Part 14,出⾃MPEG-4标准第14部分 。它是⼀种多媒体格式容器,⼴泛⽤于包装视频和⾳频数据流、海报、字幕和元数据等。(顺便⼀提,⽬前流⾏的视频编码格式AVC/H264
定义在MPEG-4 Part 10)。
概述
mp4⽂件由box组成,每个box分为Header和Data。其中Header部分包含了box的类型和⼤⼩,Data包含了⼦box或者数据,box可以嵌套⼦box。
下图是⼀个典型mp4⽂件的基本结构:
MP4⽂件的基本组成单元是box,也就是说MP4⽂件是由各种各样的box组成的,有parent box,还有children box。因此,这些boxes之间存在⼀定的层次关系,总结如下表所示,表中标记出了各个box必选或可选特性,√代表Box必选。
ftyp | √ | file type and compatibility ⽂件类型和兼容性 | |||||
pdin | progressive download information | ||||||
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 数据信息box,容器 | |||||
dref | √ | data reference box, declares source(s) of media data in track 如何定位媒体信息 | |||||
stbl | √ | sample table box, container for the time/space map 包含了track中的sample的所有时间和位置信息,以及sample的编解码等信息。利⽤这个表可以解析sample的时序、类型、⼤⼩以及在各⾃存储容器中的位置。 | |||||
stsd | √ | sample descriptions (codec types,initialization etc.) 如果是视频,包含:编码类型、宽⾼、⻓度等信息;如果是⾳频,包含:声道、采样率等信息 | |||||
stts | √ | (decoding) time-to-sample描述了sample时序的映射⽅法,我们可以通过它找到任何时间的sample。 | |||||
ctts | (composition) time to sample。 | ||||||
stsc | √ | sample-to-chunk, partial data-offset information ⽤chunk组织sample可以⽅便优化数据获取,⼀个chunk包含⼀个或多个sample。 | |||||
stsz | sample sizes (framing) 每个sample的⼤⼩。虽然这⾥没有打勾,但对于mp4还是⾮常必要的。 | ||||||
stz2 | compact sample sizes (framing) | ||||||
stco | √ | chunk offset, partial data-offset information 定义了每个chunk在媒体流中的偏移位置 | |||||
co64 | 64-bit chunk offset | ||||||
stss | sync sample table (random access points) ⽤于确定media中的关键帧 | ||||||
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 | ||||||
mvex | movie extends box | ||||||
mehd | movie extends header box | ||||||
trex | √ | track extends defaults | |||||
ipmc | IPMP Control Box | ||||||
moof | movie fragment | ||||||
mfhd | √ | movie fragment header | |||||
traf | track fragment | ||||||
tfhd | √ | track fragment header | |||||
trun | track fragment run | ||||||
sdtp | independent and disposable samples | ||||||
sbgp | sample-to-group | ||||||
subs | sub-sample information | ||||||
mfra | movie fragment random access | ||||||
tfra | track fragment random access | ||||||
mfro | √ | movie fragment random access offset | |||||
mdat | media data container | ||||||
free | free space | ||||||
skip | free space | ||||||
udta | user-data | ||||||
cprt | copyright etc. | ||||||
meta | metadata | ||||||
hdlr | √ | handler, declares the metadata (handler) type | |||||
dinf | data information box, container | ||||||
dref | data reference box, declares source(s) of metadata items | ||||||
ipmc | IPMP Control Box | ||||||
iloc | item location | ||||||
ipro | item protection | ||||||
sinf | protection scheme information box | ||||||
frma | original format box | ||||||
imif | IPMP Information box | ||||||
schm | scheme type box | ||||||
schi | scheme information box | ||||||
iinf | item information | ||||||
xml | XML container | ||||||
bxml | binary XML container | ||||||
pitm | primary item reference | ||||||
fiin | file delivery item information | ||||||
paen | partition entry | ||||||
fpar | file partition | ||||||
fecr | FEC reservoir | ||||||
segr | file delivery session group | ||||||
gitn | group id to name | ||||||
tsel | track selection | ||||||
meco | additional metadata container | ||||||
mere | metabox relation |
本⽂使⽤mediainfo和mp4box进⾏分析
图中看到mp4⽂件由⼏个主要组成部分,下⾯以
标签:10,3780,Sample,--,chunk,bytes,音视频,sample,flag From: https://www.cnblogs.com/waitmoon/p/17375337.html