shaka-project / shaka-player

JavaScript player library / DASH & HLS client / MSE-EME player
Apache License 2.0
7.08k stars 1.33k forks source link

live stream plays in Dash IF ref player but cannot find segment in Shaka #386

Closed mlondon1 closed 8 years ago

mlondon1 commented 8 years ago

Hi, My unencrypted live Dash stream plays in the Dash IF 1.6 reference player but not in Shaka. The warnings look like this. Any ideas?

(audio:1) cannot find segment: currentPeriod.startTime=0 lookupTime=1463687662.014
streaming_engine.js:1015 (video:7) cannot find segment: currentPeriod.startTime=0 lookupTime=1463687662.016

Here is my live MPD:

<?xml version="1.0" encoding="utf-8"?>
<MPD
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="urn:mpeg:dash:schema:mpd:2011"
  xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd"
  type="dynamic"
  availabilityStartTime="1970-01-01T00:00:00Z"
  publishTime="2016-05-19T20:51:40.688913Z"
  minimumUpdatePeriod="PT2S"
  timeShiftBufferDepth="PT28.032S"
  maxSegmentDuration="PT3S"
  minBufferTime="PT10S"
  profiles="urn:mpeg:dash:profile:isoff-live:2011,urn:com:dashif:dash264">
  <Period
    id="1"
    start="PT0S">
    <BaseURL>events(1463685677)/dash/</BaseURL>
    <AdaptationSet
      group="1"
      contentType="audio"
      lang="en"
      minBandwidth="64000"
      maxBandwidth="64000"
      segmentAlignment="true"
      audioSamplingRate="48000"
      mimeType="audio/mp4"
      codecs="mp4a.40.2">
      <AudioChannelConfiguration
        schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
        value="2">
      </AudioChannelConfiguration>
      <SegmentTemplate
        timescale="48000"
        initialization="channel2-$RepresentationID$.dash"
        media="channel2-$RepresentationID$-$Time$.dash"
        startNumber="1">
        <SegmentTimeline>
          <S t="258499584" d="96255" />
          <S d="96256" />
          <S d="96257" />
          <S d="96255" />
          <S d="95232" />
          <S d="96256" />
          <S d="96257" />
          <S d="96255" />
          <S d="96256" />
          <S d="96257" />
          <S d="95232" />
          <S d="96255" />
          <S d="96256" />
          <S d="96257" />
          <S d="96255" />
        </SegmentTimeline>
      </SegmentTemplate>
      <Representation
        id="audio_1=64000"
        bandwidth="64000">
      </Representation>
    </AdaptationSet>
    <AdaptationSet
      group="1"
      contentType="audio"
      lang="en"
      minBandwidth="384000"
      maxBandwidth="384000"
      segmentAlignment="true"
      audioSamplingRate="48000"
      mimeType="audio/mp4"
      codecs="ac-3">
      <SegmentTemplate
        timescale="48000"
        initialization="channel2-$RepresentationID$.dash"
        media="channel2-$RepresentationID$-$Time$.dash"
        startNumber="1">
        <SegmentTimeline>
          <S t="258594816" d="96768" />
          <S d="95232" />
          <S d="96768" />
          <S d="95232" />
          <S d="96768" r="1" />
          <S d="95232" />
          <S d="96768" />
          <S d="95232" />
          <S d="96768" />
          <S d="95232" />
          <S d="96768" />
          <S d="95232" />
          <S d="96768" />
        </SegmentTimeline>
      </SegmentTemplate>
      <Representation
        id="audio_2=384000"
        bandwidth="384000">
      </Representation>
    </AdaptationSet>
    <AdaptationSet
      group="3"
      contentType="text"
      minBandwidth="64000"
      maxBandwidth="64000"
      mimeType="application/mp4"
      codecs="stpp">
      <Role
        schemeIdUri="urn:mpeg:dash:role:2011"
        value="caption">
      </Role>
      <SegmentTemplate
        timescale="1000"
        initialization="channel2-$RepresentationID$.dash"
        media="channel2-$RepresentationID$-$Time$.dash"
        startNumber="1">
        <SegmentTimeline>
          <S t="5387382" d="2002" r="14" />
        </SegmentTimeline>
      </SegmentTemplate>
      <Representation
        id="caption_1=64000"
        bandwidth="64000">
      </Representation>
    </AdaptationSet>
    <AdaptationSet
      group="2"
      contentType="video"
      par="16:9"
      minBandwidth="1700000"
      maxBandwidth="4500000"
      minWidth="640"
      maxWidth="1920"
      minHeight="360"
      maxHeight="1080"
      segmentAlignment="true"
      frameRate="30000/1001"
      mimeType="video/mp4"
      startWithSAP="1">
      <SegmentTemplate
        timescale="30000"
        initialization="channel2-$RepresentationID$.dash"
        media="channel2-$RepresentationID$-$Time$.dash"
        startNumber="1">
        <SegmentTimeline>
          <S t="161621460" d="60060" r="14" />
        </SegmentTimeline>
      </SegmentTemplate>
      <Representation
        id="video=1700000"
        bandwidth="1700000"
        width="640"
        height="360"
        codecs="avc1.4D401E"
        scanType="progressive">
      </Representation>
      <Representation
        id="video=2700000"
        bandwidth="2700000"
        width="960"
        height="540"
        codecs="avc1.4D401F"
        scanType="progressive">
      </Representation>
      <Representation
        id="video=3200000"
        bandwidth="3200000"
        width="1280"
        height="720"
        codecs="avc1.4D401F"
        scanType="progressive">
      </Representation>
      <Representation
        id="video=4500000"
        bandwidth="4500000"
        width="1920"
        height="1080"
        codecs="avc1.4D4028"
        scanType="progressive">
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>
joeyparrish commented 8 years ago

I notice that you don't have a UTCTiming element, which is important for clock synchronization. Odds are good that your client's clock is off.

What version of Shaka Player are you using? (shaka.Player.version) Are you using your own app or our demo app to test?

In v2.0.0-beta2, we introduced two changes related to clock sync:

  1. A warning that says A UTCTiming element should always be given in live manifests! (1fb7892)
  2. A configure() setting (manifest.dash.clockSyncUri) for a default clock sync URI. (0a3d6bd)
mlondon1 commented 8 years ago

I am using the demo hosted player (v2.0.0-beta2-debug): http://shaka-player-demo.appspot.com/demo/

We also suspected it was an issue with the clock not properly being UTC. We will check the encoder settings. We would still see this issue in a pre 2.0.0-beta2 build right?

-Thanks, Marc

tdrews commented 8 years ago

Hi, apart from missing a UTCTiming element, it looks availabilityStartTime is incorrect.

In general, the t= values in each SegmentTimeline (after dividing by timescale) should be around now - availabilityStartTime. This can be accomplished by setting availabilityStartTime to the publish time of the very first MPD (so long as the first timestamp in the first segment is 0).

tab1293 commented 8 years ago

Can somebody please elaborate on what it means to add a UTCTiming element and how to configure a clockSyncUri? Is setting the clockSyncUri as simple as player.configure({ clockSyncUri: [uri] }); ? Should that URI point to the same server the player is hosted on? Also is the UTCTiming element something that needs to be added to my manifest? Why are these two things needed?

I am getting these warnings from the player:

(video:1) cannot find segment: currentPeriod.startTime=0 lookupTime=25453.112666654586
(audio:5) cannot find segment: currentPeriod.startTime=0 lookupTime=25454.111666727065

Sometimes after multiple refreshes of my player test page, the stream will load, but it is very inconsistent.

Here is what my manifest looks like

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MPD 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="urn:mpeg:dash:schema:mpd:2011" 
    xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd" 
    profiles="urn:mpeg:dash:profile:isoff-live:2011" 
    type="dynamic" 
    minBufferTime="PT4.7S" 
    suggestedPresentationDelay="PT4S" 
    minimumUpdatePeriod="PT4S" 
    availabilityStartTime="2016-06-15T07:59:02" 
    publishTime="2016-06-15T08:02:44">
  <Period start="PT0.0S">
    <AdaptationSet contentType="video" segmentAlignment="true" bitstreamSwitching="true">
      <Representation id="360p-video" mimeType="video/mp4" codecs="avc1.4d401e" width="640" height="360" frameRate="30/1">
        <SegmentTemplate timescale="15360" initialization="360p/init-stream0.m4s" media="360p/chunk-stream0-$Number%05d$.m4s" startNumber="1">
          <SegmentTimeline>
            <S t="0" d="77312"/>
            <S d="122880"/>
            <S d="44032"/>
            <S d="114176"/>
            <S d="98304"/>
            <S d="128000"/>
            <S d="46080"/>
            <S d="20480"/>
            <S d="66560"/>
            <S d="94208"/>
            <S d="128000"/>
            <S d="31744"/>
            <S d="67072"/>
            <S d="40448"/>
            <S d="164864"/>
            <S d="41984"/>
            <S d="96768"/>
            <S d="27136"/>
            <S d="84480"/>
            <S d="63488"/>
            <S d="66560"/>
            <S d="80896"/>
            <S d="93184"/>
            <S d="53248"/>
            <S d="88064"/>
            <S d="80896"/>
            <S d="95232"/>
            <S d="67584"/>
            <S d="100352"/>
            <S d="33280"/>
            <S d="128000" r="1"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
      <Representation id="540p-video" mimeType="video/mp4" codecs="avc1.64001f" width="960" height="540" frameRate="30/1">
        <SegmentTemplate timescale="15360" initialization="540p/init-stream0.m4s" media="540p/chunk-stream0-$Number%05d$.m4s" startNumber="1">
          <SegmentTimeline>
            <S t="0" d="77312"/>
            <S d="122880"/>
            <S d="44032"/>
            <S d="114176"/>
            <S d="64512"/>
            <S d="161792"/>
            <S d="46080"/>
            <S d="20480"/>
            <S d="66560"/>
            <S d="94208"/>
            <S d="128000"/>
            <S d="31744"/>
            <S d="66048"/>
            <S d="41472"/>
            <S d="164864"/>
            <S d="41984"/>
            <S d="96768"/>
            <S d="27136"/>
            <S d="84480"/>
            <S d="63488"/>
            <S d="66560"/>
            <S d="80896"/>
            <S d="93184"/>
            <S d="53248"/>
            <S d="88064"/>
            <S d="80896"/>
            <S d="95232"/>
            <S d="67584"/>
            <S d="100352"/>
            <S d="33280"/>
            <S d="69120"/>
            <S d="116224"/>
            <S d="87552"/>
            <S d="54272"/>
            <S d="86016"/>
            <S d="57856"/>
            <S d="128000"/>
            <S d="103936"/>
            <S d="125952"/>
            <S d="128000"/>
            <S d="30720"/>
            <S d="60416"/>
            <S d="27136"/>
            <S d="68096"/>
            <S d="44032"/>
            <S d="73216"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
      <Representation id="144p-video" mimeType="video/mp4" codecs="avc1.4d400d" width="256" height="144" frameRate="30/1">
        <SegmentTemplate timescale="15360" initialization="144p/init-stream0.m4s" media="144p/chunk-stream0-$Number%05d$.m4s" startNumber="1">
          <SegmentTimeline>
            <S t="0" d="77312"/>
            <S d="122880"/>
            <S d="44032"/>
            <S d="114176"/>
            <S d="98304"/>
            <S d="128000"/>
            <S d="46080"/>
            <S d="20480"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
    <AdaptationSet contentType="audio" segmentAlignment="true" bitstreamSwitching="true">
      <Representation id="360p-audio" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="128000" audioSamplingRate="48000">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
        <SegmentTemplate timescale="48000" initialization="360p/init-stream1.m4s" media="360p/chunk-stream1-$Number%05d$.m4s" startNumber="1">
          <SegmentTimeline>
            <S t="0" d="238600"/>
            <S d="384000"/>
            <S d="138240"/>
            <S d="356352"/>
            <S d="307200"/>
            <S d="400384"/>
            <S d="143360"/>
            <S d="64512"/>
            <S d="207872"/>
            <S d="293888"/>
            <S d="400384"/>
            <S d="99328"/>
            <S d="209920"/>
            <S d="125952"/>
            <S d="515072"/>
            <S d="131072"/>
            <S d="303104"/>
            <S d="83968"/>
            <S d="264192"/>
            <S d="198656"/>
            <S d="207872"/>
            <S d="252928"/>
            <S d="290816"/>
            <S d="166912"/>
            <S d="275456"/>
            <S d="252928"/>
            <S d="296960"/>
            <S d="210944"/>
            <S d="314368"/>
            <S d="103424"/>
            <S d="400384"/>
            <S d="399360"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
      <Representation id="540p-audio" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="256000" audioSamplingRate="48000">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
        <SegmentTemplate timescale="48000" initialization="540p/init-stream1.m4s" media="540p/chunk-stream1-$Number%05d$.m4s" startNumber="1">
          <SegmentTimeline>
            <S t="0" d="238600"/>
            <S d="384000"/>
            <S d="138240"/>
            <S d="356352"/>
            <S d="201728"/>
            <S d="505856"/>
            <S d="143360"/>
            <S d="64512"/>
            <S d="207872"/>
            <S d="293888"/>
            <S d="400384"/>
            <S d="99328"/>
            <S d="206848"/>
            <S d="129024"/>
            <S d="515072"/>
            <S d="131072"/>
            <S d="303104"/>
            <S d="83968"/>
            <S d="264192"/>
            <S d="198656"/>
            <S d="207872"/>
            <S d="252928"/>
            <S d="290816"/>
            <S d="166912"/>
            <S d="275456"/>
            <S d="252928"/>
            <S d="296960"/>
            <S d="210944"/>
            <S d="314368"/>
            <S d="103424"/>
            <S d="216064"/>
            <S d="363520"/>
            <S d="273408"/>
            <S d="169984"/>
            <S d="268288"/>
            <S d="181248"/>
            <S d="399360"/>
            <S d="325632"/>
            <S d="393216"/>
            <S d="400384"/>
            <S d="95232"/>
            <S d="189440"/>
            <S d="83968"/>
            <S d="212992"/>
            <S d="138240"/>
            <S d="228352"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
      <Representation id="144p-audio" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="96000" audioSamplingRate="48000">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
        <SegmentTemplate timescale="48000" initialization="144p/init-stream1.m4s" media="144p/chunk-stream1-$Number%05d$.m4s" startNumber="1">
          <SegmentTimeline>
            <S t="0" d="238600"/>
            <S d="384000"/>
            <S d="138240"/>
            <S d="356352"/>
            <S d="307200"/>
            <S d="400384"/>
            <S d="143360"/>
            <S d="64512"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>
joeyparrish commented 8 years ago

Can somebody please elaborate on what it means to add a UTCTiming element?

A UTCTiming element is an XML element in your manifest that specifies how the client should synchronize its clock with your server. Here's an example:

<?xml version="1.0" encoding="utf-8"?>
<MPD type="dynamic" availabilityStartTime="1970-01-01T00:00:00Z">
  <UTCTiming schemeIdUri="urn:mpeg:dash:utc:direct:2014" value="1970-01-01T00:00:30Z" />
  <Period>
    <!-- ... -->
  </Period>
</MPD>

If your manifest is being generated on-the-fly, you can directly include the current time in the UTCTiming element with the scheme direct:2014:

<UTCTiming schemeIdUri="urn:mpeg:dash:utc:direct:2014"
           value="1970-01-01T00:00:00Z" />

You can have the client get the time from the HTTP Date header of a particular resource using the scheme http-head:2014:

<UTCTiming schemeIdUri="urn:mpeg:dash:utc:http-head:2014"
           value="http://foo.bar/check_me_for_the_date_header" />

You can also have a dynamically generated page on the server which itself contains the current time in XML date format (such as 1970-01-01T00:00:00Z):

<UTCTiming schemeIdUri="urn:mpeg:dash:utc:http-xsdate:2014"
           value="http://foo.bar/my_body_is_the_current_date_and_time" />

Is setting the clockSyncUri as simple as player.configure({ clockSyncUri: [uri] }); ?

Yes, except it's a string and not an array of strings. The URI you specify will be treated as if it was attached to the http-head:2014 scheme. The HTTP Date header from that URI will be used to synchronize the client's clock.

Should that URI point to the same server the player is hosted on?

It can work either way, but if the clock sync URI is on a different origin than the player, it will be a cross-origin request. You can read more about CORS on MDN.

Why are these two things needed?

You don't need both. If the UTCTiming element is in the manifest, the client can synchronize its clock by that. If not, the configured URI will be used as a fallback. This is useful if you are not in control of the contents of the manifest for some reason.

Clock sync is critical for live playback, as the client must know what segments are available when. An individual client's clock can be potentially very far off, but even small inaccuracies can have a big impact on playback.

Does that help?