MP4文件格式具体解释——结构概述
MP4文件格式具体解释(ISO-14496-12/14)
Author:Pirate Leo
Email:codeevoship@gmail.com
一、基本概念
1、 文件,由很多Box和FullBox组成。
2、 Box,每一个Box由Header和Data组成。
3、 FullBox,是Box的扩展,Box结构的基础上在Header中添加8bits version和24bits flags。
4、 Header,包括了整个Box的长度size和类型type。当size==0时,代表这是文件里最后一个Box;当size==1时,意味着Box长度须要很多其它bits来描写叙述,在后面会定义一个64bits的largesize描写叙述Box的长度;当type是uuid时,代表Box中的数据是用户自己定义扩展类型。
5、 Data,是Box的实际数据,能够是纯数据也能够是很多其它的子Boxes。
6、 当一个Box的Data中是一系列子Box时,这个Box又可成为Container Box。
Box的结构用伪代码表演示样例如以下:
aligned(8) class Box (unsigned int(32) boxtype,optional unsigned int(8)[16] extended_type)
{
unsigned int(32) size;
unsigned int(32) type = boxtype;
if (size==1)
{
unsigned int(64) largesize;
}
else if (size==0)
{
// box extends to end of file
}
if (boxtype==‘uuid’)
{
unsigned int(8)[16] usertype = extended_type;
}
结构例如以下图:

文件基本结构描写叙述图
二、MP4文件格式(ISO-14496-12/14)
MP4文件概述
MP4文件就是由各式各样的Box组成的,下表中列出了全部必选或可选的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 |
|||||
|
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 |
||||||
|
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 |
正式開始前先对文件的几个重要部分宏观介绍一下,以便诸位在兴许学习时心中有数:
1、 ftypbox,在文件的開始位置,描写叙述的文件的版本号、兼容协议等;
2、 moovbox,这个box中不包括详细媒体数据,但包括本文件里全部媒体数据的宏观描写叙述信息,moov box下有mvhd和trak box。
>>mvhd中记录了创建时间、改动时间、时间度量标尺、可播放时长等信息。
>>trak中的一系列子box描写叙述了每一个媒体轨道的详细信息。
3、 moofbox,这个box是视频分片的描写叙述信息。并非MP4文件必须的部分,但在我们常见的可在线播放的MP4格式文件里(比如Silverlight Smooth Streaming中的ismv文件)确是重中之重。
4、 mdatbox,实际媒体数据。我们终于解码播放的数据都在这里面。
5、 mfrabox,一般在文件末尾,媒体的索引文件,可通过查询直接定位所需时间点的媒体数据。

附:Smooth Streaming中ismv文件结构,文件分为了多个Fragments,每一个Fragment中包括moof和mdat。这种结构符合渐进式播放需求。(mdat及其描写叙述信息逐步传输,收齐一个Fragment便可播放当中的mdat)。
MP4文件格式具体解释——结构概述的更多相关文章
- MP4文件格式
MP4文件格式详解(ISO-14496-12/14) Author:Pirate Leo Email:codeevoship@gmail.com 一.基本概念 1. 文件,由许多Box和FullBox ...
- mp4文件格式解析
目前MP4的概念被炒得很火,也很乱.最开始MP4指的是音频(MP3的升级版),即MPEG-2 AAC标准.随后MP4概念被转移到视频上,对应的是MPEG-4标准.而现在我们流行的叫法,多半是指能播放M ...
- mp4文件格式解析(转载)
mp4文件格式解析 原作:http://blog.sina.com.cn/s/blog_48f93b530100jz4b.html 目前MP4的概念被炒得很火,也很乱.最开始MP4指的是音频(MP3的 ...
- mp4文件格式解析二
目前MP4的概念被炒得很火,也很乱.最开始MP4指的是音频(MP3的升级版),即MPEG-2 AAC标准.随后MP4概念被转移到视频上,对应的是MPEG-4标准.而现在我们流行的叫法,多半是指能播放M ...
- 5分钟入门MP4文件格式
写在前面 本文主要内容包括,什么是MP4.MP4文件的基本结构.Box的基本结构.常见且重要的box介绍.普通MP4与fMP4的区别.如何通过代码解析MP4文件 等. 写作背景:最近经常回答团队小伙伴 ...
- MP4文件格式的解析
MP4文件格式的解析,以及MP4文件的分割算法 mp4应该算是一种比较复杂的媒体格式了,起源于QuickTime.以前研究的时候就花了一番的功夫,尤其是如何把它完美的融入到视频点播应用中,更是费尽了心 ...
- mp4文件格式之fragment mp4
目前网络上对mp4文件格式的总结已经相当多了,我就不在这里抄别人总结的东西了,想入门的话百度一下会有许多这方面的文章.这里介绍一下其他文章中很少涉及的一种mp4文件结构,即fragment mp4,也 ...
- openssl之EVP系列之7---信息摘要算法结构概述
openssl之EVP系列之7---信息摘要算法结构概述 ---依据openssl doc/crypto/EVP_DigestInit.pod翻译和自己的理解写成 (作者:Dragon ...
- BMP文件格式具体解释
BMP文件格式具体解释(BMP file format) BMP文件格式,又称为Bitmap(位图)或是DIB(Device-Independent Device,设备无关位图),是Windows系统 ...
随机推荐
- 【程序猿助手】Emacs,最强的编辑器,之间的不
wx_fmt=png" alt="" style="max-width:100%; height:auto!important"> 内容简单 ...
- Android_使用StrictMode
调试开发
本博文为子墨原创,转载请注明出处! http://blog.csdn.net/zimo2013/article/details/40076049 1.StrictMode简单介绍 自Android 2 ...
- c语言 int (*p)[5] 类型分析
#include<stdio.h> int main() { int i; int b[5]={1,3,5,7,9}; int (*a)[5] = &b ...
- Linux下一个OTL 采用long long类型数据库支持BIGINT
码如下面: #define OTL_BIGINT long long #define OTL_STR_TO_BIGINT(str,n) \ { \ n=atoll(str); \ } #define ...
- 【JUnit4.10来源分析】6 Runner
org.junit.runner.Runner它是JUnit作业引擎.它在许多类型的支持下的.处理试验和生产(Description).Failure和Result和其它输出. Runner参见图主类 ...
- MongoDB:逐渐变得无关紧要
我与MongoDB的关系可分为三个阶段.对于目前处于第三阶段的我来说,这款产品似乎变得无关紧要了.很快你就会明白为什么我这么说. 阶段一:痴迷 我与MongoDB的第一次接触十分神奇:一个poligl ...
- sqlite 中文排序
看 http://www.cnblogs.com/08shiyan/archive/2012/05/11/2496491.html 这个方法 不太好用 最好的办法是 表添加pinyin字段. 插入数据 ...
- HDU 3831 DICS
意甲冠军: 按标题给4操作模式 用最少的次数 离a串行转换b弦 思路: 因为操作仅仅有这4种 所以我们能够确定从头到位去匹配a和b一定是正确的 那么状态数一共同拥有多少呢 一共同拥有lengt ...
- 【Android进阶】Application对象的详解
1:Application是什么? Application和Activity,Service一样,是android框架的一个系统组件,当android程序启动时系统会创建一个 application对 ...
- 学习swift语言的快速入门教程推荐
随着苹果产品越来越火爆,苹果新推出的swift必定将在很大程度上代替oc语言.学好swift语言,对于IOS工程师来讲,已经是一门必备技能. 有一些比较好的英文版教程,值得学习. 1. Swift T ...