Dash-Industry-Forum / dash.js

A reference client implementation for the playback of MPEG DASH via Javascript and compliant browsers.
http://reference.dashif.org/dash.js/nightly/samples/dash-if-reference-player/index.html
Other
5.1k stars 1.67k forks source link

Automatically extended SegmentTimeline #4046

Open bill42362 opened 1 year ago

bill42362 commented 1 year ago

Is your feature request related to a problem? Please describe.

Our livestream .mpd set minBufferTime="PT1S" minimumUpdatePeriod="PT3S" timeShiftBufferDepth="PT15S" suggestedPresentationDelay="PT3S", Cache-Control of the mpd file is max-age=3~2, and our stream segment is around 3s (<S d="270000" r="5"/> + timescale="90000").

<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" profiles="urn:mpeg:dash:profile:isoff-live:2011" minBufferTime="PT1S" type="dynamic" publishTime="2022-09-20T06:41:33Z" availabilityStartTime="2022-09-20T06:28:32Z" minimumUpdatePeriod="PT3S" timeShiftBufferDepth="PT15S" suggestedPresentationDelay="PT3S">
...
  <SegmentTemplate timescale="90000" initialization="preview-00000.clear.mp4" media="preview-$Number%05d$.clear.m4s" startNumber="257">
      <SegmentTimeline>
          <S t="69156000" d="270000" r="5"/>
      </SegmentTimeline>
  </SegmentTemplate>
...
</MPD>

The problem is with these config, sometimes when we update the mpd (minimumUpdatePeriod="PT3S"), the previous mpd still be cached on CDN, which leads to dashjs have no new segments to play, then after player run out of buffer, it will increase live delay from ~3s to ~6s, to stabilize playing.

Describe the solution you'd like

A built-in config to enable player to auto extend the <SegmentTimeline>, like append the last segment twice to assume the next segment's filename and t, d.

Basically doing what this article mentions: https://www.unified-streaming.com/blog/stop-numbering-underappreciated-power-dashs-segmenttimeline

A player can easily extend the timeline on its own. This works similar to calculating the availability of the next segment when numbered segments are used.

To calculate the timestamp of the next segment, the player can simply take the timestamp of the most recent segment and add it to the timing information of the media contained in the segment (signaled in the ​‘tfdt’-box of the fMP4). No wall clock needed, no rocket science involved.

Describe alternatives you've considered

Additional context

BTW, what's the recommend config combination of using <SegmentTimeline>? What's the normal value should we put for suggestedPresentationDelay, Cache-Control, minimumUpdatePeriod and suggestedPresentationDelay?

Thanks.

bill42362 commented 1 year ago

Similar feature request have open on shaka-player in 2017 :( https://github.com/shaka-project/shaka-player/issues/898