I have a DASH stream (.mpd), how do I get all the fragments and resolution in it

964 Views Asked by At

If an MPD file has a section that looks like this, how do I parse it to get the title and resolution? I need this array to create multiple videos for me to render, or switch the resolution of the stream.

   <SupplementalProperty schemeIdUri="urn:mpeg:dash:srd:2014" value="0,0,0,1,1,3,3"/>
   <Representation id="1" mimeType="video/mp4" codecs="hev2.1.6.L186.0" width="640" height="360" frameRate="24" sar="1:1" startWithSAP="1" bandwidth="131694">
    <SegmentTemplate timescale="24000" media="sequence_qp22_dash_track1_$Number$.m4s" startNumber="1" duration="25008" initialization="hevc_srd_set1_init.mp4"/>
   </Representation>
  </AdaptationSet>
  <AdaptationSet segmentAlignment="true" maxWidth="640" maxHeight="360" maxFrameRate="24" par="16:9" lang="und">
   <SupplementalProperty schemeIdUri="urn:mpeg:dash:srd:2014" value="0,1,0,1,1,3,3"/>
   <Representation id="3" mimeType="video/mp4" codecs="avc1.4d401e" width="640" height="360" frameRate="24" sar="1:1" startWithSAP="1" bandwidth="131424">
    <SegmentTemplate timescale="24000" media="tile2-360p-128kbps_dash$Number$.m4s" startNumber="1" duration="25008" initialization="tile2-360p-128kbps_dashinit.mp4"/>
   </Representation>
   <Representation id="4" mimeType="video/mp4" codecs="avc1.4d401e" width="640" height="360" frameRate="24" sar="1:1" startWithSAP="1" bandwidth="1492186">
    <SegmentTemplate timescale="24000" media="tile2-360p-1500kbps_dash$Number$.m4s" startNumber="1" duration="25008" initialization="tile2-360p-1500kbps_dashinit.mp4"/>
   </Representation>
  </AdaptationSet>
  <AdaptationSet segmentAlignment="true" maxWidth="640" maxHeight="360" maxFrameRate="24" par="16:9" lang="und">
   <SupplementalProperty schemeIdUri="urn:mpeg:dash:srd:2014" value="0,2,0,1,1,3,3"/>
   <Representation id="5" mimeType="video/mp4" codecs="avc1.4d401e" width="640" height="360" frameRate="24" sar="1:1" startWithSAP="1" bandwidth="129740">
    <SegmentTemplate timescale="24000" media="tile3-360p-128kbps_dash$Number$.m4s" startNumber="1" duration="25008" initialization="tile3-360p-128kbps_dashinit.mp4"/>
   </Representation>
   <Representation id="6" mimeType="video/mp4" codecs="avc1.4d401e" width="640" height="360" frameRate="24" sar="1:1" startWithSAP="1" bandwidth="1451324">
    <SegmentTemplate timescale="24000" media="tile3-360p-1500kbps_dash$Number$.m4s" startNumber="1" duration="25008" initialization="tile3-360p-1500kbps_dashinit.mp4"/>
   </Representation>
  </AdaptationSet>
1

There are 1 best solutions below

1
yolostreet On

The title would be found within a element, although this is optional and most mpds omit it.

The whole presentation is divided into adaption sets, each of which contains collections of representations. Usually, there is at least one adaptation set for video and one for audio. The snippet you have provided looks like an mpd intended for a tiled display of VR content, as it is the implementation of MPEG-DASH Spatial Relation Description elements. It contains multiple video adaption sets, each with only one representation or two representations.

The resolution can be retrieved by parsing the width and height attributes from each representation, for example width="640" height="360".