shaka-project / shaka-player

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

DASH + multiple subtitles adaptation sets issue #4650

Open Robloche opened 1 year ago

Robloche commented 1 year ago

Have you read the FAQ and checked for duplicate open issues? Yes.

What version of Shaka Player are you using? 4.2.3.

Can you reproduce the issue with our latest release version? Not tried.

Can you reproduce the issue with the latest code from main? Not tried.

Are you using the demo app or your own custom app? My own app.

If custom app, can you reproduce the issue using our demo app? Not tried.

What browser and OS are you using? Chrome 107.0.5304.88 (Build officiel) (64 bits) Windows Windows 10 Professionnel 21H2

What are the manifest and license server URIs? Manifest excerpt:

<AdaptationSet
        id="3"
        group="3"
        contentType="text"
        lang="fr"
        mimeType="application/mp4"
        codecs="wvtt"
        startWithSAP="1">
    <Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
    <Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
    <SegmentTemplate
            timescale="1000"
            initialization="1167569875-1665437344_france-domtom_DRM-$RepresentationID$.dash"
            media="1167569875-1665437344_france-domtom_DRM-$RepresentationID$-$Time$.dash">
        <SegmentTimeline>
            <S t="0" d="10000" r="259"/>
            <S d="2480"/>
        </SegmentTimeline>
    </SegmentTemplate>
    <Representation
            id="textstream_fre=1000"
            bandwidth="1000">
    </Representation>
</AdaptationSet>
<AdaptationSet
        id="4"
        group="3"
        contentType="text"
        lang="fr"
        mimeType="text/vtt">
    <Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
    <Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
    <Representation
            id="988352792"
            bandwidth="1000">
        <BaseURL>textstream_fre=1000.webvtt</BaseURL>
    </Representation>
</AdaptationSet>

What did you expect to happen? As per specification, if several AdaptationSet with the same group are present, ony one should be presented: https://dashif.org/docs/DASH-IF-IOP-v4.2-clean.htm#:~:text=Only%20one%20Representation%20in%20a%20Group%20is%20intended%20to%20be%20presented%20at%20a%20time. So, getTextTracks() should return onyl 1 subtitles track.

What actually happened? getTextTracks() returns the 2 subtitles tracks.

joeyparrish commented 1 year ago

I can see from your example that the two tracks are equivalent in language, and only differ in format.

This is analogous to video and audio, where you may have the same resolutions/languages available in multiple codecs.

For video and audio, we select a single codec early, because we don't yet have the ability to switch codecs during a presentation. (See #1528.) However, that is not the case for text. Because text stream parsing happens at the JavaScript level, we can switch between text streams without concern for their format or codec.

If we should only return one track in your case, how should we choose?

For audio and video, we introduced some configurations to let applications decide how we choose. (See preferredVideoCodecs and preferredAudioCodecs under https://shaka-player-demo.appspot.com/docs/api/shaka.extern.html#.PlayerConfiguration)

Should we introduce a similar config for text? Something like:

player.configure('preferredTextFormats', [
  'wvtt',  // in MP4
  'text/vtt',  // as text
]);
avelad commented 1 year ago

I'm agree with adding preferredTextFormats if we have the same language, same role, and forced.

Robloche commented 1 year ago

Thanks for answering. I really like the preferredTextFormats option, indeed.

But besides that, the player should choose and present only one text track (maybe the first one?) per group. Is your understanding of the spec different from mine?