Support CMAF subtitles in HLS
[REQUIRED] Use case description
While testing some HLS content on Exoplayer (2.11.4), I noticed that the subtitles in the following stream provoke a fatal exception and cause playback to fail.
https://irtdashreference-i.akamaihd.net/dash/live/901161/keepixo1/playlistBR2.m3u8
This is the stack trace:
com.google.android.exoplayer2.source.hls.SampleQueueMappingException: Unable to bind a sample queue to TrackGroup with mime type text/vtt.
at com.google.android.exoplayer2.source.hls.HlsSampleStream.maybeThrowError(HlsSampleStream.java:64)
at com.google.android.exoplayer2.BaseRenderer.maybeThrowStreamError(BaseRenderer.java:143)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:645)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:329)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:223)
at android.os.HandlerThread.run(HandlerThread.java:67)
The stream contains a SUBTITLES tag as follows:
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="T1",NAME="sub-de",LANGUAGE="de",DEFAULT=YES,AUTOSELECT=YES,URI="6fb1fbbc3158544d5d5ed2b3bc06a991-3-subtitle_08-playlist.m3u8"
Having a look at the HLS parser I notice that it tries to guess the mime type based on codec info, but since it's not present, it defaults to VTT. This explains the fatal exception. The codec/mime info cannot be guessed at this point.
There are additional streams listed where I found the previous one: http://subtitling.irt.de/cmaf/#urls
The device used is a Pixel 2 running Android R preview, but I don't think that's relevant.
Proposed solution
I'd expect Exo to parse the SUBTITLES tag properly as a playlist, manage it like any other playlist and properly extract the subtitles out of the mp4 segments. This behaviour is already present with the MPD counterpart, which is playing as expected:
https://irtdashreference-i.akamaihd.net/dash/live/901161/keepixo1/manifestBR2.mpd
Alternatives considered
I'm aware of the possibility of just using a subtitle file in the SUBTITLE tag, nevertheless, we find this a valid use case.
@AquilesCanta This may be fixed by the fix for VTT format parsing from this: https://github.com/google/ExoPlayer/pull/7184
The URI is not valid so I can't help verify if the pull request fixes this too. The whole business of matching CODECs from variants to the Renditions (MEDIA) is a bit janky for HLS.
Hi @jtreveset, can you check your request is fixed in the dev-v2 branch?
The provided URL is returning 404.
Indeed, unfortunately, the original streams are now down. We will try to come up with a similar stream for testing. I'll let you know once I have more info.
Hey @jtreveset. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Since there haven't been any recent updates here, I am going to close this issue.
@jtreveset if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.