videojs / mpd-parser

https://videojs.github.io/mpd-parser/
Other
78 stars 54 forks source link

Parsing error for representations without segment info #164

Open nhasselmeyer opened 1 year ago

nhasselmeyer commented 1 year ago

The following file fails to parse:

<?xml version="1.0" encoding="UTF-8"?>
<MPD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:cenc="urn:mpeg:cenc:2013" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd" type="static" minBufferTime="PT30S" profiles="urn:mpeg:dash:profile:isoff-main:2011" mediaPresentationDuration="PT1M4.800S">
  <Period start="PT0S" duration="PT1M4.800S" id="1">
    <AdaptationSet mimeType="video/webm" frameRate="30/1" segmentAlignment="true" subsegmentAlignment="true" startWithSAP="1" subsegmentStartsWithSAP="1" bitstreamSwitching="false">
      <Representation id="1" width="1920" height="1080" bandwidth="1800000" codecs="vp9">
        <BaseURL>864_vp9.webm</BaseURL>
      </Representation>
    </AdaptationSet>
    <AdaptationSet mimeType="audio/mp4" lang="eng" segmentAlignment="0">
      <Representation id="2" bandwidth="96000" audioSamplingRate="48000" codecs="mp4a.40.2">
        <BaseURL>864_aac.mp4</BaseURL>
        <SegmentBase indexRange="658-961">
          <Initialization range="0-657"/>
        </SegmentBase>
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>

The problem seems to be in https://github.com/videojs/mpd-parser/blob/d7261e907c460ed21d186f0b094f61f66a1cffae/src/toPlaylists.js#L21-L27 For the first representation, there are no elements with any segment information, so segmentsFn is not set. The toM3u8 function requires segmentsInfo.segments to be a list, leading to a error that is hard to debug (trying to call undefined.reduce())