Skip to content

duration calculated from segmentIndex mismatches whats available in periodInfo #187

Closed
@priyajeet

Description

@priyajeet

I have the following MPD

<MPD mediaPresentationDuration="PT1M3.7S" minBufferTime="PT10.0S" type="static" profiles="urn:mpeg:dash:profile:isoff-live:2011" xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Period start="PT0.0S">
        <AdaptationSet maxFrameRate="24" bitstreamSwitching="true" segmentAlignment="true" contentType="video">
            <Representation height="800" width="1920" bandwidth="8000000" codecs="avc1.640028" mimeType="video/mp4" id="0">
                <SegmentTemplate startNumber="2" initialization="dash_1080.1.m4s" media="dash_1080.$Number$.m4s" duration="5000000" timescale="1000000"></SegmentTemplate>
            </Representation>
            <Representation height="354" width="854" bandwidth="2000000" codecs="avc1.42c01e" mimeType="video/mp4" id="1">
                <SegmentTemplate startNumber="2" initialization="dash_480.1.m4s" media="dash_480.$Number$.m4s" duration="5000000" timescale="1000000"></SegmentTemplate>
            </Representation>
        </AdaptationSet>
        <AdaptationSet bitstreamSwitching="true" segmentAlignment="true" contentType="audio">
            <Representation audioSamplingRate="44100" bandwidth="128290" codecs="mp4a.40.2" mimeType="audio/mp4" id="2">
                <AudioChannelConfiguration value="2" schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011"/>
                <SegmentTemplate startNumber="2" initialization="dash_audio.1.m4s" media="dash_audio.$Number$.m4s" duration="5000000" timescale="1000000"></SegmentTemplate>
            </Representation>
        </AdaptationSet>
    </Period>
</MPD>

The <MPD> tag has the mediaPresentationDuration="PT1M3.7S" signifying the video is ~63 seconds. However when loading the video, it reports the duration as ~65 seconds which it is calculating by

  for (var i = 0; i < segmentIndexes.length; ++i) {
    var seekRange = segmentIndexes[i].getSeekRange();
    startTime = Math.max(startTime, seekRange.start);
    if (seekRange.end != null) {
      endTime = Math.min(endTime, seekRange.end);
    }
  }

inside shaka.player.StreamVideoSource.prototype.computeStreamLimits_

As there are 13 available segments, it multiplies by 5s per segment, giving a total of 65s.
The last segment is however not a full 5s segment, so when the playback ends, it throws a warning from the else clause of shaka.player.StreamVideoSource.prototype.setUpMediaSource_

If I now add duration="PT1M3.7S" to the <Period> tag in the MPD, it still has the same issue, since fetching duration from the periodInfo happens after calculating it from the segmentIndex inside shaka.player.StreamVideoSource.prototype.computeStreamLimits_ and is protected by a endTime == Number.POSITIVE_INFINITY check.

if (endTime == Number.POSITIVE_INFINITY) {
    // TODO(story 1890046): Support multiple periods.
    var period = this.manifestInfo.periodInfos[0];
    if (period.duration) {
      endTime = (period.start || 0) + period.duration;
    } else {
      shaka.log.debug('Failed to compute a stream end time.');
      return null;
    }
  }

Questions:

  1. Is the MPD I have seem / look correct? Or is it lacking information that is messing with the player calculations?
  2. shaka-player is using mediaPresentationDuration="PT1M3.7S" to figure out the number of segments = var numSegments = Math.ceil(this.period_.duration / scaledSegmentDuration); = 1M3.7S / 5S = 13. However if it is doing that, shouldn't it know that the 13th segment is only seekable to 3.7s and not the total 5s? And why is this duration not being used as opposed to recalculating it again by iterating over all the segments?
  3. Why is segmentIndex seekable ranges given preference over period duration?
  4. Why is there not a fallback to just use mediaPresentationDuration="PT1M3.7S" as the duration incase its not available on the <Period> tag?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: archivedArchived and locked; will not be updatedtype: bugSomething isn't working correctly

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions