google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.74k stars 6.03k forks source link

416 http response code when requesting ttml subtitles #2259

Closed PavelGP closed 7 years ago

PavelGP commented 7 years ago
<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" id="165" type="dynamic" publishTime="2016-12-23T11:22:40" minimumUpdatePeriod="PT30S" availabilityStartTime="2016-12-19T13:09:00" minBufferTime="PT30S" suggestedPresentationDelay="PT25.00S" timeShiftBufferDepth="PT60.00S" profiles="urn:mpeg:dash:profile:isoff-live:2011">
  <Period start="PT0.00S" id="1">
    <AdaptationSet mimeType="video/mp4" segmentAlignment="true" subsegmentAlignment="true" startWithSAP="1" subsegmentStartsWithSAP="1" bitstreamSwitching="true">
      <Representation id="1" width="852" height="480" frameRate="25/1" bandwidth="1200000" codecs="avc1.4D401E">
        <SegmentTemplate timescale="90000" media="165_video_1_0_$Number$.mp4?m=1482151120" initialization="165_video_1_0_init.mp4?m=1482151120" startNumber="33918">
          <SegmentTimeline>
            <S t="30524404500" d="900000" r="5"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
      <Representation id="2" width="640" height="360" frameRate="25/1" bandwidth="600000" codecs="avc1.4D401E">
        <SegmentTemplate timescale="90000" media="165_video_1_1_$Number$.mp4?m=1482151120" initialization="165_video_1_1_init.mp4?m=1482151120" startNumber="33918">
          <SegmentTimeline>
            <S t="30524404500" d="900000" r="5"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
    <AdaptationSet mimeType="audio/mp4" segmentAlignment="0">
      <Representation id="3" bandwidth="64422" audioSamplingRate="32000" codecs="mp4a.40.2">
        <SegmentTemplate timescale="90000" media="165_audio_1_2_$Number$.mp4?m=1482151120" initialization="165_audio_1_2_init.mp4?m=1482151120" startNumber="33918">
          <SegmentTimeline>
            <S t="30524405760" d="901440"/>
            <S t="30525307200" d="898560"/>
            <S t="30526205760" d="901440"/>
            <S t="30527107200" d="898560"/>
            <S t="30528005760" d="901440"/>
            <S t="30528907200" d="898560"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
      <Representation id="4" bandwidth="64422" audioSamplingRate="32000" codecs="mp4a.40.2">
        <SegmentTemplate timescale="90000" media="165_audio_1_3_$Number$.mp4?m=1482151120" initialization="165_audio_1_3_init.mp4?m=1482151120" startNumber="33918">
          <SegmentTimeline>
            <S t="30524405760" d="901440"/>
            <S t="30525307200" d="898560"/>
            <S t="30526205760" d="901440"/>
            <S t="30527107200" d="898560"/>
            <S t="30528005760" d="901440"/>
            <S t="30528907200" d="898560"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
    <AdaptationSet mimeType="application/mp4" codecs="stpp" segmentAlignment="true" subsegmentAlignment="true" startWithSAP="1" subsegmentStartsWithSAP="1" bitstreamSwitching="true" lang="nor">
      <Representation id="5" bandwidth="0">
        <SegmentTemplate timescale="90000" media="165_subtitles_1_5_$Number$.mp4?m=1482151120" initialization="165_subtitles_1_5_init.mp4?m=1482151120" startNumber="33918">
          <SegmentTimeline>
            <S t="30524404500" d="900000" r="5"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
    <AdaptationSet mimeType="application/mp4" codecs="stpp" segmentAlignment="true" subsegmentAlignment="true" startWithSAP="1" subsegmentStartsWithSAP="1" bitstreamSwitching="true" lang="swe">
      <Representation id="6" bandwidth="0">
        <SegmentTemplate timescale="90000" media="165_subtitles_1_4_$Number$.mp4?m=1482151120" initialization="165_subtitles_1_4_init.mp4?m=1482151120" startNumber="33918">
          <SegmentTimeline>
            <S t="30524404500" d="900000" r="5"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>
ojw28 commented 7 years ago

It looks like the first failure is that ExoPlayer doesn't find the track in the moov atom, which is part of the initialization chunk. The problem could be with the content (i.e. the initialization chunk failing the declare the track or declaring it incorrectly), or an issue with ExoPlayer (i.e. the extractor failing to handle the way in which the track is declared). It's likely the 416 issue occurs only as a knock-on effect of the first failure.

We don't need full access to the content to investigate, but we do need you to provide the problematic initialization chunk. You can either attach it to this issue, or email it to dev.exoplayer@gmail.com.

PavelGP commented 7 years ago

Thank you, please follow the link to find initialization chunk: https://drive.google.com/file/d/0B1Agf5-0EdOXN3ZDbUVWTUdNTmc/view?usp=sharing

ojw28 commented 7 years ago

The initialization chunk is invalid. Specifically, the stsd box is empty. It should contain an XMLSubtitleSampleEntry() (i.e. an stpp box) for the text track. Please take a look at "ISO 14496-12 Amendment 2: Carriage of timed text and other visual overlays", which describes what should be present.

PavelGP commented 7 years ago

Thank you very much, but didn't understand why web players play this stream without fail and show subtitles.

ojw28 commented 7 years ago

Whether non-compliant media plays successfully often comes down to exactly how the player is implemented. In this case the reason ExoPlayer is looking in the stsd box in to determine the type of the track. The track type is also defined in the DASH manifest (codecs="stpp"), and so it's likely that the web players you mention get the track type from the manifest and don't bother looking in the stsd box for it. Doing this would make sense if you were building a DASH only player. However for regular FMP4 playbacks there is no DASH manifest. Looking in the stsd box is the only way to go in that case. Since ExoPlayer supports regular FMP4 playbacks (and FMP4 in SmoothStreaming / HLS) in addition to DASH, and since we don't want to maintain multiple code paths, we look in the stsd box in all cases.