`
yuanlanjun
  • 浏览: 1184303 次
文章分类
社区版块
存档分类
最新评论

MP4文件格式详解——元数据moov(三)tref box

 
阅读更多

元数据moov(三)tref 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


本次分析tref box——TrackReferenceBox

由于我本地没有找到包含tref box的MP4文件,因此无法以实际数据分析。

但通过协议足以使我们明白tref box的作用:

tref box可以描述两track之间关系。

比如:一个MP4文件中有三条video track,ID分别是2、3、4,以及三条audio track,ID分别是6、7、8。

在播放track 2视频时到底应该采用6、7、8哪条音频与其配套播放?这时候就需要在track 2与6的tref box中指定一下,将2与6两条track绑定起来。


在我们常见的MP4文件中几乎看不到这种情况的存在,实际应用场景在哪呢?

我们知道,ISO-14496-12是一种基础文件格式,从这种文件格式衍生出的不仅mp4文件,还有很多用于在线实时交付的流媒体视频格式,比如微软的Smooth Streaming的解决方案中的ismv文件。

假设我们是一家电视台,我们采用了微软的Smooth Streaming技术进行节目发布,我们推出了13套节目,分别是CCAV 1-13。这时候我们服务器推出的媒体流可能只有一个。这个流中包含了全部的13套节目,至少有13条视频轨与13条音频轨。用户在收看节目时使用了某公司生产的类似机顶盒似的硬件设备,可以解码与播放,但是必须要找到每套节目对应的视频与音频(不能播放CCAV 5篮球赛画面的同时配上了CCAV 13的共同关注声音)。这时候就需要通过tref box将视频与音频之间的关系一一对应起来。

这就是tref box的实际应用场景之一,有些类似ts格式中的PAT,PMT。在官方协议中描述了另一种应用,即,参考时钟track,简单理解就是音视频在此处都引用了同一个time code track,以使音视频同步播放,类似ts格式中PCR与各track的PTS关系。

下面看具体字段:

aligned(8) class TrackReferenceBox extends Box(‘tref’) 
{

} 
aligned(8) class TrackReferenceTypeBox (unsigned int(32) reference_type) extends Box(reference_type) 
{
  unsigned int(32) track_IDs[]; 
} 

顾名思意,tref box用于列出本track解析时所参考的track有哪些。

每个trak box中只能包含[0-1]个tref box;(通常情况下,我们所见的MP4文件是没有tref box的)

每个tref box下面可以包含1个以上的tref type box;

引用Apple官方给出的结构图如下:


在Apple协议中,atom是box的另一种名称;图中可知tref box中包含多个子box,每个子box需要填写type和track ID。

Type的填写参照下表(Apple定义):

Track reference types

Reference type

Description

'tmcd'

Time code. Usually references a time code track.

'chap'

Chapter or scene list. Usually references a text track.

'sync'

Synchronization. Usually between a video and sound track. Indicates that the two tracks are synchronized. The reference can be from either track to the other, or there may be two references.

'scpt'

Transcript. Usually references a text track.

'ssrc'

Non-primary source. Indicates that the referenced track should send its data to this track, rather than presenting it. The referencing track will use the data to modify how it presents its data. See“Track Input Map Atoms”for more information.

'hint'

The referenced tracks contain the original media for this hint track.

ISO-14496-12又重新整理了这些type字段为以下三种:

• ‘hint’ the referenced track(s) contain the original media for this hint track
• ‘cdsc‘ this track describes the referenced track.
• ‘hind‘ this track depends on the referenced hint track, i.e., it should only be used if the referenced
hint track is used.



分享到:
评论

相关推荐

    mp4文件格式解析 box说明

    MP4文件中的所有数据都装在box(QuickTime中为atom)中,也就是说MP4文件由若干个box组成,每个box有类型和长度,可以将box理解为一个数据对象块。box中可以包含另一个box,这种box称为container box。一个MP4文件...

    mp4转换为边下边播格式(moov前置)

    此程序将MP4文件转换为可边下边播的MP4文件 使用方式: 1.将要转换的MP4文件复制到文件夹src中 2.双击convert.bat执行转换,等待完成 3.转换完成的文件存储在文件夹target 注意: 此程序将会转换src目录下的所有MP4...

    mp4box.js-3d-old:Fork for mp4 与 X3D 场景测试

    MP4Box.js 在浏览器中处理 MP4 ... 创建一个 MP4Box 对象,设置onReady回调并以 ArrayBuffer 对象的形式提供数据。 MP4Box.js 支持渐进式解析。 您可以一次提供小缓冲区,当解析“moov”框时将调用回调。 var mp4bo

    mp4box.js:GPAC的MP4Box工具JavaScript版本

    MP4Box.js JavaScript库可在浏览器(和NodeJS)中处理MP4文件,并支持渐进式解析。 灵感来自项目的工具。 它可以用于: , MP4文件以与, 从MP4中样本以创建TextTracks。 在此页面上,您会找到有关如何 ,或或进行...

    mp4结构查看器

    mp4结构查看器,包括了mp4,3gp的结构查看功能,方便用来分析视频文件结构

    QuikTime File Format(MP4格式文档)

    MP4文件格式分析 英文版 MP4文件头,ftyp,moov,mvhd,trak,tkhd 等等的最全面描述

    qt-faststart:移动文件顶部的“moov”原子并通过添加适当的偏移量更新所有“stco”子原子指针

    这是唯一一个从 Quick Time 电影文件(.mov、mp4)中读取 moov atom metada 的 C 程序,它不使用任何外部源代码和库,只使用标准的 C 库。 与ffmpeg的源代码不同的是: 它使用fcntl.h open/close/lseek/read 而不是...

    ngx_http_enhance_mp4_module:原始 nginx_http_mp4_module 的增强版本,它自动将 moov atom 从最后一个文件移动到文件开头,以启用文件可以立即流式传输而不是下载整个文件

    该模块使 nginx mp4 模块能够动态修改 mp4 文件( moov atom 放置在文件的最后一个)(仅一次),然后将其传送到视频播放器。这就是为什么为了提供 HTTP(RTMP 和其他可以做得更好)视频点播(使用ngx_...

    ffmpeg 合并文件异常.txt

    问题描述 https://stackoverflow.com/questions/44374790/ffmpeg-concat-protocol-error-found-duplicated-moov-atom-skipped-it ...本资源采用 ffmpeg concat 命令前,将mp4文件转换为指定编码后即可顺利合并为1个

    SourceCode.zip (Mp4 View VC2010)

    VC2010 编译成功, C语言解析MP4文件,逐个BOX分析,可以用来学习MP4格式。 解析MP4 Box模型,ftyp,moov, mdat , moov(mvhd , track。。。。 )。

    3gp,mp4,m4a,mov编辑器

    可将 MP4/M4A/M4V/MOV/3GP/3GP2/3GPP/3G2 等文件按照持续时间/轨道数目/文件大小任意分割,或将其所支持的全部视频/音频格式合并为 MPEG-4/3GPP 文件。 3):轨道抽取: 可任意抽取容器文件中的视频、音频、文本...

    Mio Moov 200 firmware

    Mio Moov 200 original firmware V1.00.0025

    mp4v2封装MP4示例工程

    MP4 视频格式处理的利器!封装 H264 和 AAC 到 MP4 中的经典,可以音视频同步、设置任意分辨率、录制时间!

    f4v-moov

    f4v-moov

    MoovMisManage:Moovbox 管理不善工具

    Moovbox 管理不善实用程序。 来自 Icomera Moovbox 产品的材料(工具、代码、密钥和证书)的转储,针对 BSides Hannover 谈话进行了逆向工程。 幻灯片 您可以找到幻灯片 内容 ###./openvpn_keys:从设备中提取的 ...

    mp4info.exe

    可以非常清晰地看到查看mp4类型多媒体文件的ftyp/moov/mdat等信息.绿色软件,打开即用。非常小巧

    mp4 info查看工具

    可以查看mp4的box 比较方便直观,很容易可以看到moov里面的trak stbl box的内容

    paperclip-av-qtfaststart:修复 FFmpeg MP4 视频文件

    当 FFmpeg 生成 mp4 文件时,它会将 moov 原子放在最后,使其无法流式传输。 要解决此问题,请在使用对视频文件进行转码后使用此处理器运行 qtfaststart 在您的模型中: class Lesson ...

    faststarFramework:mp4的moov置前

    faststarFrameworkfaststarVideoFramework前面写到,有个被偏方取代的问题,就是部分mp4中moov位于末尾无法实现边下边播的问题。先找到了解决方案,并写了个库供大家使用:// mp4的moov置前#import &lt;Foundation&gt;@...

    Mp4 Box infomation

    按字节将Mp4 box解析为树,显示在树控件中

Global site tag (gtag.js) - Google Analytics