Number of segments in a DASH MPD

user3284980 picture user3284980 · Feb 7, 2014 · Viewed 9.3k times · Source

How can I determine the number of segments of a DASH media if the MPD file doesn't have any segment URL's lists? It only has a segment template, so I don't know how many segments the media associated to this MPD has. This is the MPD I'm talking about:

<MPD type="static" xmlns="urn:mpeg:DASH:schema:MPD:2011" profiles="urn:mpeg:dash:profile:full:2011" minBufferTime="PT1.5S" mediaPresentationDuration="PT0H1M59.89S">
 <ProgramInformation moreInformationURL="http://gpac.sourceforge.net">
  <Title>Media Presentation Description for file hdworld_0696kbps_ffmpeg_track1.mp4 generated with GPAC </Title>
 </ProgramInformation>
 <Period start="PT0S" duration="PT0H1M59.89S">
  <AdaptationSet>
   <ContentComponent id="1" contentType="video"/>
   <SegmentTemplate initialization="/$Bandwidth$/hdworld_ffmpeg_track1_dash.mp4" timescale="1000" duration="4920" media="/$Bandwidth$/hdworld_ffmpeg_track1_$Number$.m4s" startNumber="1"/>
   <Representation id="1" mimeType="video/mp4" codecs="avc1.64001f" width="1280" height="720" startWithSAP="1" bandwidth="534343"/>   
   <Representation id="2" mimeType="video/mp4" codecs="avc1.64001f" width="1280" height="720" startWithSAP="1" bandwidth="812553"/>
   <Representation id="3" mimeType="video/mp4" codecs="avc1.64001f" width="1280" height="720" startWithSAP="1" bandwidth="1607692"/>
  </AdaptationSet>
   <AdaptationSet>
   <ContentComponent id="2" contentType="audio" lang="und"/>
   <SegmentTemplate initialization="/audio/HDWorld_audio_init.mp4"/>
   <Representation id="6" mimeType="audio/mp4" codecs="mp4a.40.02" sampleRate="44100" numChannels="2" lang="und" startWithSAP="1" bandwidth="257141">
    <SegmentTemplate timescale="1000" duration="9980" media="/audio/hdworld_seg_audio$Number$.m4s" startNumber="1"/>
   </Representation>
  </AdaptationSet>
 </Period>
</MPD>

My goal is to retrieve all existent segments' URIs.

Answer

user3288575 picture user3288575 · Feb 9, 2014

In this example, you can see the audio segments are each 9.98 seconds long (duration=9980, timescale=1000). Since the duration of the presentation is 1m 59.89s, (duration="PT0H1M59.89S"), that's about 13 segments (the last one being shorter). Use the URL template (/audio/hdworld_seg_audio$Number$.m4s) to retrieve each segment (replace $Number$ with the segment number you want (the first one being 1). The same applies for video segments (except that they are 4.92 seconds each, so you'll have 25 segments)