mov tref box——TrackReferenceBox



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关系。

下面看具体字段:

[cpp]   view plain  copy
  1. aligned(8) class TrackReferenceBox extends Box(‘tref’)   
  2. {  
  3.   
  4. }   
  5. aligned(8) class TrackReferenceTypeBox (unsigned int(32) reference_type) extends Box(reference_type)   
  6. {  
  7.   unsigned int(32) track_IDs[];   
  8. }   

扫描二维码关注公众号,回复: 957456 查看本文章

顾名思意,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. 

猜你喜欢

转载自blog.csdn.net/datamining2005/article/details/80061315
Box