Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to filter VTT text tracks in AndroidX Media 1.4.0? #1782

Open
jpgpuyo opened this issue Oct 6, 2024 · 1 comment
Open

How to filter VTT text tracks in AndroidX Media 1.4.0? #1782

jpgpuyo opened this issue Oct 6, 2024 · 1 comment

Comments

@jpgpuyo
Copy link

jpgpuyo commented Oct 6, 2024

Hello,

I have detected a different behaviour between AndroidX Media 1.3.0 and AndroidX Media 1.4.0.
I would like to filter VTT text tracks.

Below I show a sample code to explain this question.

In AndroidX media 1.3.0, I'm doing it in the following way:

override fun onTracksChanged(tracks: Tracks) {
...
tracks.groups.filter{ 
    it.type == C.TRACK_TYPE_TEXT && 
    it.mediaTrackGroup.getFormat(0).sampleMimeType == "text/vtt" }
...
}

Now, in version AndroidX Media 1.4.0, I have to do the following:

override fun onTracksChanged(tracks: Tracks) {
...
tracks.groups.filter{ 
    it.type == C.TRACK_TYPE_TEXT && 
    it.mediaTrackGroup.getFormat(0).sampleMimeType == "application/x-media3-cues"  &&
     it.mediaTrackGroup.getFormat(0).codecs == "text/vtt"
}
...
}

In this particular case, we are not using the Exoplayer subtitles view, we are using our custom view, so I need to retrieve VTT tracks. I have checked release notes but I am not sure where this change is explained.

Is it the expected behaviour or this should be reported as a new bug?
Which is the right way to filter VTT text tracks?

Thanks!

@icbaker
Copy link
Collaborator

icbaker commented Oct 7, 2024

Is it the expected behaviour or this should be reported as a new bug?

The change in MIME type is expected - because from 1.4.0 onwards the bytes written into the SampleQueue for a WebVTT subtitle track are no longer WebVTT UTF-8 text, but instead a media3-specific serialization of the subtitle data - hence the change in MIME type (because the parsing logic for these bytes also needs to change).


In this particular case, we are not using the Exoplayer subtitles view, we are using our custom view, so I need to retrieve VTT tracks. I have checked release notes but I am not sure where this change is explained.

Could you elaborate on this part a bit more - are you parsing the WebVTT data yourself (so you want to consume the UTF-8 text data directly), or are you consuming Cue objects from Player.Listener.onCues or similar? If you are consuming the Cue objects, could you add some more detail on why you care about the 'original' subtitle format (since the Cue object is format-agnostic)? This will help me understand the best way to help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants