atitit.mp4 视频文件多媒体格式结构详解
atitit.mp4 视频文件多媒体格式结构详解
MP4文件格式详解(ISO-14496-12/14)
Author:Pirate Leo
Email:codeevoship@gmail.com
1. 一、基本概念
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。
作者:: 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 汉字名:艾龙, EMAIL:1466519819@qq.com
转载请注明来源: http://www.cnblogs.com/attilax/
二、MP4文件格式(ISO-14496-12/14)
2. MP4文件概述
MP4文件就是由各式各样的Box组成的,下表中列出了所有必选或可选的Box类型,√代表Box必选。
具体列表:
正式开始前先对文件的几个重要部分宏观介绍一下,以便诸位在后续学习时心中有数:
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,一般在文件末尾,媒体的索引文件,可通过查询直接定位所需时间点的媒体数据。
3. mp4是由一个个“box”组成的,
大box中存放小box,一级嵌套一级来存放媒体信息。box的基本结构是:

其中,size指明了整个box所占用的大小,包括header部分。如果box很大(例如存放具体视频数据的mdat box),超过了uint32的最大数值,size就被设置为1,并用接下来的8位uint64来存放大小。
4. 典型简化mp4
一个mp4文件有可能包含非常多的box,在很大程度上增加了解析的复杂性,这个网页上http://mp4ra.org/atoms.html记录了一些当前注册过的box类型。看到这么多box,如果要全部支持,一个个解析,怕是头都要爆了。还好,大部分mp4文件没有那么多的box类型,下图就是一个简化了的,常见的mp4文件结构:

一般来说,解析媒体文件,最关心的部分是视频文件的宽高、时长、码率、编码格式、帧列表、关键帧列表,以及所对应的时戳和在文件中的位置,这些信息,在mp4中,是以特定的算法分开存放在stbl box下属的几个box中的,需要解析stbl下面所有的box,来还原媒体信息。下表是对于以上几个重要的box存放信息的说明:

Ref MP4文件格式的解析,以及MP4文件的分割算法 - haibindev - 博客园.htm
5.
Fragments

附:Smooth Streaming中ismv文件结构,文件分为了多个Fragments,每个Fragment中包含moof和mdat。这样的结构符合渐进式播放需求。(mdat及其描述信息逐步传输,收齐一个Fragment便可播放其中的mdat)。
6. ref
MP4文件格式详解——结构概述 - 胡同里的庇护所(Pirate Leo's Shelter) - 博客频道 - CSDN.NET.htm
7. 具体列表
|
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 |
8. Ref2
视频文件头解析--MP4_意思_新浪博客.htm
atitit.mp4 视频文件多媒体格式结构详解的更多相关文章
- HTML video 视频标签全属性详解
HTML 5 video 视频标签全属性详解 现在如果要在页面中使用video标签,需要考虑三种情况,支持Ogg Theora或者VP8(如果这玩意儿没出事的话)的(Opera.Mozilla.C ...
- HTML-▲▲video 视频标签全属性详解▲▲
HTML 5 video 视频标签全属性详解 现在如果要在页面中使用video标签,需要考虑三种情况,支持Ogg Theora或者VP8(如果这玩意儿没出事的话)的(Opera.Mozilla.C ...
- 音视频入门-14-JPEG文件格式详解
* 音视频入门文章目录 * JPEG 文件格式解析 JPEG 文件使用的数据存储方式有多种.最常用的格式称为 JPEG 文件交换格式(JPEG File Interchange Format,JFIF ...
- Multipart/form-data POST文件上传详解
Multipart/form-data POST文件上传详解 理论 简单的HTTP POST 大家通过HTTP向服务器发送POST请求提交数据,都是通过form表单提交的,代码如下: <form ...
- Linux "ls -l"文件列表权限详解
ls Linux "ls -l"文件列表权限详解 1.使用 ls -l 命令 执行结果如下(/var/log) : drwxr-x--- root adm -- : apache2 ...
- C#文件后缀名详解
C#文件后缀名详解 .sln:解决方案文件,为解决方案资源管理器提供显示管理文件的图形接口所需的信息. .csproj:项目文件,创建应用程序所需的引用.数据连接.文件夹和文件的信息. .aspx:W ...
- Multipart/form-data POST文件上传详解(转)
Multipart/form-data POST文件上传详解 理论 简单的HTTP POST 大家通过HTTP向服务器发送POST请求提交数据,都是通过form表单提交的,代码如下: <form ...
- iOS回顾笔记(03) -- 自定义View的封装和xib文件的使用详解
iOS回顾笔记(03) -- 自定义View的封装和xib文件的使用详解 iOS开发中,我们常常将一块View封装起来,以便于统一管理内部的子控件.如iOS回顾笔记(02)中的"书" ...
- Linux学习之文件特殊权限详解(SetUID、SetGID、Sticky BIT)(十一)
Linux学习之文件特殊权限详解(SetUID.SetGID.Sticky BIT) 目录 SetUID SetGID Sticky BIT SetUID SetUID简介 只有可以执行的二进制程序和 ...
随机推荐
- linux 系统运维
Linux 系统监控1.进程 查看所有进程 ps -ef ps -ef |grep nginx 结束进程 # 结束进程号为5031 kill -g 5031 # 结束 ...
- Go语言TCP/UDP Socket编程
1. TCP编程 TCPClient // TCPClient project main.go package main import ( "fmt" "net" ...
- [转]不定义JQuery插件,不要说会JQuery
一:导言 有些WEB开发者,会引用一个JQuery类库,然后在网页上写一写("#"),("."),写了几年就对别人说非常熟悉JQuery.我曾经也是这样的人,直 ...
- Into concurrent LRU caching once again
But this time, with a more product oriented point of view, instead of researching. http://openmymind ...
- Innodb Read IO 相关参数源代码解析
前言:最近在阅读Innodb IO相关部分的源代码.在阅读之前一直有个疑问,show global status 中有两个指标innodb_data_reads 和 innodb_data_read. ...
- Tips11:用[Rang]来限制Inspector中的变量
我们在写脚本的过程中可能会用到很多Public变量,如INT型,Float型,这些变量在项目中可能有着一个默认的实际范围,如血量不能为负数,而且int float本来就是有一个范围的,如果对这些变量加 ...
- MyBatis魔法堂:各数据库的批量Update操作
一.前言 MyBatis的update元素的用法与insert元素基本相同,因此本篇不打算重复了.本篇仅记录批量update操作的sql语句,懂得SQL语句,那么MyBatis部分的操作就简单了. ...
- CentOS6.5菜鸟之旅:文件权限详解
一.前言 Linux下所有资源.设备均被视作文件来操作,而文件权限则是决定用户可各文件操作的范围,无论是平时使用Linux,还是写程序均涉及这方面.以下为个人学习的整理,供以后查阅. 二. 三种权限 ...
- 转载:第五弹!全球首个微信小程序(应用号)开发教程!通宵吐血赶稿,每日更新!
博卡君今天继续更新,忙了一天,终于有时间开工写教程.不罗嗦了,今天我们来看看如何实现一些前端的功能和效果. 第八章:微信小程序分组开发与左滑功能实现 先来看看今天的整体思路: 进入分组管理页面--&g ...
- SQL Server 2005 Service Broker
一.引言 SQL Server 2005 的一个主要成就是可以实现可靠.可扩展且功能完善的数据库应用程序.与 .NET Framework 2.0 公共语言运行库 (CLR) 的集成使开发人员可以将重 ...
Fragments5