mpeg dash简单介绍

来源:互联网 发布:淘宝学生平价女装店 编辑:程序博客网 时间:2024/05/18 22:53

MPEG DASH也是一个主流的直播点播流媒体协议,而且兼容HLS。只不过相对复杂,下面作为简介进行介绍。


首先,解析一个dash流需要对应MPD文件(Media Presentation Description),相当于hls的m3u8文件。MPD文件是xml格式的。下面从外到内介绍MPD文件的主要成员。


1. period:一个mpeg dash流由1~n个period组成,并且标有这个period的起始时间和结束时间。例如

 <Period start="PT0S" duration="PT0H10M0.00S">

2. Adaptationset:period由1~n个Adaptation set组成,每个adaptation set包含一种内容的多个码率等等,比如一个包含视频内容的adaptation set如下,里面可以有多种码率的视频

  <AdaptationSet segmentAlignment="true" maxWidth="1920" maxHeight="1080" maxFrameRate="25" par="16:9">   <ContentComponent id="1" contentType="video"/>

相对的,一个包含音频内容:

  <AdaptationSet segmentAlignment="true" lang="und">   <ContentComponent id="1" contentType="audio" lang="und"/>

3. Representation:adaptation set由1~n个representation组成,每一组都可以有不同的分辨率,码率,对音频来说可以有不同的声道。

比如视频的,他们都在一个adaptation set里:

<Representation id="h264bl_low" mimeType="video/mp4" codecs="avc1.42c00d" width="320" height="180" frameRate="25" sar="1:1" startWithSAP="1" bandwidth="50877">
<Representation id="h264bl_mid" mimeType="video/mp4" codecs="avc1.42c01e" width="640" height="360" frameRate="25" sar="1:1" startWithSAP="1" bandwidth="194870">
   <Representation id="h264bl_hd" mimeType="video/mp4" codecs="avc1.42c01f" width="1280" height="720" frameRate="25" sar="1:1" startWithSAP="1" bandwidth="514828">

音频的,这几个在同一个音频的adaptation set里:

<Representation id="aaclc_low" mimeType="audio/mp4" codecs="mp4a.40.2" audioSamplingRate="44100" lang="und" startWithSAP="1" bandwidth="19079">
<Representation id="aaclc_high" mimeType="audio/mp4" codecs="mp4a.40.2" audioSamplingRate="44100" lang="und" startWithSAP="1" bandwidth="66378">

4. Segment:在representation下面就是segment了,这个和hls基本一致,可以直观理解为提供给客户端读取读对应文件url。常常使用fmp4格式,不过和hls有所区别的是,它可以不像hls一样把文件切成多个ts文件,而是以一个fmp4文件为基准,以不同的bytes range来标识不同的segment,这样离线文件只有一个fmp4。下面这个例子是分成多个m4s文件的切片,

    <SegmentList timescale="1000" duration="10000">     <Initialization sourceURL="mp4-main-multi-h264bl_low-.mp4"/>    <SegmentURL media="mp4-main-multi-h264bl_low-1.m4s"/>    <SegmentURL media="mp4-main-multi-h264bl_low-2.m4s"/>
... 

下面是IEEE文档中的图,总结一下结构:



最后,呈上一段MPD比较完整的例子:

<?xml version="1.0"?>
<!-- MPD file Generated with GPAC version 0.5.1-DEV-rev4193 -->
<MPD type="static" xmlns="urn:mpeg:DASH:schema:MPD:2011" minBufferTime="PT1.5S" mediaPresentationDuration="PT0H10M0.00S" profiles="urn:mpeg:dash:profile:isoff-main:2011">
 <ProgramInformation moreInformationURL="http://gpac.sourceforge.net">
  <Title>mp4-main-multi-mpd-AV-NBS.mpd generated by GPAC</Title>
  <Copyright>TelecomParisTech(c)2012</Copyright>
 </ProgramInformation>
 <Period start="PT0S" duration="PT0H10M0.00S">
  <AdaptationSet segmentAlignment="true" maxWidth="1920" maxHeight="1080" maxFrameRate="25" par="16:9">
   <ContentComponent id="1" contentType="video"/>
   <Representation id="h264bl_low" mimeType="video/mp4" codecs="avc1.42c00d" width="320" height="180" frameRate="25" sar="1:1" startWithSAP="1" bandwidth="50877">
    <SegmentList timescale="1000" duration="10000">
     <Initialization sourceURL="mp4-main-multi-h264bl_low-.mp4"/>
    <SegmentURL media="mp4-main-multi-h264bl_low-1.m4s"/>
    <SegmentURL media="mp4-main-multi-h264bl_low-2.m4s"/>
    ......
    </SegmentList>
   </Representation>
   <Representation id="h264bl_mid" mimeType="video/mp4" codecs="avc1.42c01e" width="640" height="360" frameRate="25" sar="1:1" startWithSAP="1" bandwidth="194870">
    <SegmentList timescale="1000" duration="10000">
     <Initialization sourceURL="mp4-main-multi-h264bl_mid-.mp4"/>
    <SegmentURL media="mp4-main-multi-h264bl_mid-1.m4s"/>
    <SegmentURL media="mp4-main-multi-h264bl_mid-2.m4s"/>
    ......
    </SegmentList>
   </Representation>
   <Representation id="h264bl_hd" mimeType="video/mp4" codecs="avc1.42c01f" width="1280" height="720" frameRate="25" sar="1:1" startWithSAP="1" bandwidth="514828">
    <SegmentList timescale="1000" duration="10000">
     <Initialization sourceURL="mp4-main-multi-h264bl_hd-.mp4"/>
    <SegmentURL media="mp4-main-multi-h264bl_hd-1.m4s"/>
    <SegmentURL media="mp4-main-multi-h264bl_hd-2.m4s"/>
    ......
    </SegmentList>
   </Representation>
   <Representation id="h264bl_full" mimeType="video/mp4" codecs="avc1.42c028" width="1920" height="1080" frameRate="25" sar="1:1" startWithSAP="1" bandwidth="770699">
    <SegmentList timescale="1000" duration="10000">
     <Initialization sourceURL="mp4-main-multi-h264bl_full-.mp4"/>
    <SegmentURL media="mp4-main-multi-h264bl_full-1.m4s"/>
    <SegmentURL media="mp4-main-multi-h264bl_full-2.m4s"/>
    ......
    </SegmentList>
   </Representation>
  </AdaptationSet>
  <AdaptationSet segmentAlignment="true" lang="und">
   <ContentComponent id="1" contentType="audio" lang="und"/>
   <Representation id="aaclc_low" mimeType="audio/mp4" codecs="mp4a.40.2" audioSamplingRate="44100" lang="und" startWithSAP="1" bandwidth="19079">
    <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1"/>
    <SegmentList timescale="1000" duration="9520">
     <Initialization sourceURL="mp4-main-multi-aaclc_low-.mp4"/>
    <SegmentURL media="mp4-main-multi-aaclc_low-1.m4s"/>
    <SegmentURL media="mp4-main-multi-aaclc_low-2.m4s"/>
    ......
    </SegmentList>
   </Representation>
   <Representation id="aaclc_high" mimeType="audio/mp4" codecs="mp4a.40.2" audioSamplingRate="44100" lang="und" startWithSAP="1" bandwidth="66378">
    <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="1"/>
    <SegmentList timescale="1000" duration="9520">
     <Initialization sourceURL="mp4-main-multi-aaclc_high-.mp4"/>
    <SegmentURL media="mp4-main-multi-aaclc_high-1.m4s"/>
    <SegmentURL media="mp4-main-multi-aaclc_high-2.m4s"/>
    ......
    </SegmentList>
   </Representation>
  </AdaptationSet>
 </Period>
</MPD>




0 0
原创粉丝点击