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

Filter out forced subtitle tracks from StyledPlayerControlView text track selector #9432

Closed
J6ey opened this issue Sep 16, 2021 · 11 comments
Closed
Assignees

Comments

@J6ey
Copy link

J6ey commented Sep 16, 2021

I have DASH video files containing closed captions links within the mpd file, so I'm not manually adding subtitles. Some video assets have Forced language captions that I don't want to show in the player (which is showing up twice). For example, French, German, and Spanish forced should be excluded in options user can select:

French (Parisian) (Forced)
German (Germany) (Forced)
Spanish (Castilian) (Forced)

French (Parisian) (Full)
German (Germany) (Full)
Spanish (Castilian) (Full)
Marathi (Full)
Norwegian (Full)
Danish (Full)
Turkish (Full)

I'm using the default StyledPlayerView, and have tried something along the lines of

DefaultTrackSelector.Parameters parameters = trackSelector
.buildUponParameters()
.setDisabledTextTrackSelectionFlags(C.SELECTION_FLAG_FORCED)
.build();

trackSelector.setParameters(parameters);

but with no success. I'm able to see the list of subtitles available with this:

int trackLength = trackSelector.getCurrentMappedTrackInfo().getTrackGroups(2).length;
for (int i = 0; i < trackLength; i++) {
    Utils.log(trackSelector.getCurrentMappedTrackInfo().getTrackGroups(2).get(i).getFormat(0).label);
}

Not sure if changes should or can be made here to remove the unwanted captions.
Any help is appreciated, thank you.

@icbaker
Copy link
Collaborator

icbaker commented Sep 17, 2021

I think it's important to separate the player's track selection logic from what tracks are shown in a UI track selector.

TrackSelector#setParameters is all about customising the player's logic (i.e. what track(s) the player will choose to actually play).

When you pick a specific track in the track selection UI, the TrackSelector is updated to reflect this preference, and cause the player to start playing the newly selected track.

So can you please clarify:

  • Are you trying to filter the list of tracks shown to the user in a UI or actually change what subtitles are shown during playback?
  • If changing the UI: What UI component are you using to build your track selection UI?
  • If it's related to what's shown during playback please provide media we can use to reproduce the problem in the demo app. Please either upload it here or send to dev.exoplayer@gmail.com using a subject in the format Issue #1234 (where #1234 should be replaced with this issue number.) Please also update this issue to indicate you’ve done this.

but with no success. I'm able to see the list of subtitles available with this:

int trackLength = trackSelector.getCurrentMappedTrackInfo().getTrackGroups(2).length;
for (int i = 0; i < trackLength; i++) {
    Utils.log(trackSelector.getCurrentMappedTrackInfo().getTrackGroups(2).get(i).getFormat(0).label);
}

This doesn't look surprising, tracks are mapped to renderers whether they're enabled or disabled. Which track(s) of that mapping that are selected for playback is stored in a TrackSelection.

@J6ey
Copy link
Author

J6ey commented Sep 20, 2021

Are you trying to filter the list of tracks shown to the user in a UI or actually change what subtitles are shown during playback?

The first one, however, the subtitles are retrieved during Widevine playback, e.g., one of the subtitles that needs to be filtered, shown here is labeled German (Germany) (Forced).

image

If changing the UI: What UI component are you using to build your track selection UI?

I've been using
DefaultTrackSelector trackSelector = new DefaultTrackSelector(this, new AdaptiveTrackSelection.Factory());

If it's related to what's shown during playback please provide media we can use to reproduce the problem in the demo app.

I have sent the media info I've been using to test this. Thank you for your help.

@icbaker
Copy link
Collaborator

icbaker commented Sep 20, 2021

If changing the UI: What UI component are you using to build your track selection UI?

I've been using
DefaultTrackSelector trackSelector = new DefaultTrackSelector(this, new AdaptiveTrackSelection.Factory());

This isn't a UI component. From the screenshot it looks like you're using StyledPlayerView and StyledPlayerControlView from ExoPlayer's UI library - is that correct?


I have sent the media info I've been using to test this. Thank you for your help.

Thanks for the stream. The DRM license doesn't seem to work [1], but I think that's OK because I can still see all the track info for the text tracks without it.


I think there are two separate things going on here:

  1. The text track selector provided by StyledPlayerControlView doesn't filter out forced subtitle tracks from being displayed.
  2. Your DASH media doesn't correctly mark the subtitle tracks called '(Forced)' with the forced_subtitle role.

For (1): Assigning to @ojw28 to decide a sensible default behaviour here. I think it probably does make sense to always filter out forced subtitle tracks from the menu triggered by StyledPlayerControlView. In the demo app we will still also have the SELECT TRACKS button at the top which brings up the TrackSelectionDialog and imo that should not filter out forced subtitles - to allow explicitly selecting them for testing.

For (2): If your media uses the forced_subtitle annotation then this will get propagated to the Format#selectionFlags of the respective text track (as C.SELECTION_FLAG_FORCED). Without that annotation then any changes we make to StyledPlayerControlView won't work for your media.


[1]

android.media.MediaCodec$CryptoException: Crypto key not available: 1 (Unknown error -1)
...
[policy_engine.cpp(51):CanDecryptContent] Provided content key is not in license: key_id = <redacted>

@icbaker icbaker assigned ojw28 and unassigned icbaker Sep 20, 2021
@icbaker icbaker changed the title How to disable or filter out forced subtitles/closed captions? Filter out forced subtitle tracks from StyledPlayerControlView text track selector Sep 20, 2021
@ojw28
Copy link
Contributor

ojw28 commented Oct 6, 2021

For (1): Assigning to @ojw28 to decide a sensible default behaviour here. I think it probably does make sense to always filter out forced subtitle tracks from the menu triggered by StyledPlayerControlView. In the demo app we will still also have the SELECT TRACKS button at the top which brings up the TrackSelectionDialog and imo that should not filter out forced subtitles - to allow explicitly selecting them for testing.

Agreed. The change to StyledPlayerControlView is a bit more complicated than just filtering out the forced tracks, because we'll need to make it so that selecting None still selects a forced track if appropriate (currently it disables the renderer).

@ojw28 ojw28 removed the needs triage label Oct 6, 2021
@J6ey
Copy link
Author

J6ey commented Oct 7, 2021

@icbaker Yes, sorry I am using StyledPlayerView and StyledPlayerControlView. Thanks to that info, my team just added the forced_subtitle flags to our assets as it's also required for Bitmovin to display the forced captions during audio.

@ojw28 In the meantime, would I need to try customizing or overriding PlayerControlView layouts or try any workaround approach?

Thank you guys for getting to the bottom of this.

@ojw28
Copy link
Contributor

ojw28 commented Oct 7, 2021

@ojw28 In the meantime, would I need to try customizing or overriding PlayerControlView layouts or try any workaround approach?

It's not something you can solve with layout files. You would probably need to fork StyledPlayerControlView and edit the code. If you figure out a clean solution, you could also send a pull request back to the ExoPlayer project.

@ojw28
Copy link
Contributor

ojw28 commented Nov 18, 2021

Note: We should also remove references to "Auto" and just show which track is selected.

@SaurabhOfficial
Copy link

@ojw28 when no text tracks are selected shouldn't the forced-subtitle track for the audio language being played in the player, be forced in the playback, since I tried to test a stream with forced subtitle option and it shows multiple text tracks with the same language and doesn't force the subtitle tracks when no subtitle tracks are selected.
e.g if I am playing with audio track of lang_code = 'en' with no subtitle track selected shouldn't exoplayer use the en forced-subtitle track by default.
isn't this the default behavior? should it be implemented on top of the current forced_subtitle functionality based on the SELECTION_FLAG_FORCED, and use the same flag to filter out any forced-subtitle text tracks from appearing in the subtitle track selection dialog?

@icbaker
Copy link
Collaborator

icbaker commented Dec 20, 2021

@SaurabhOfficial Please file a new issue with the info requested in the template (media we can use to reproduce the issue, and a bug report taken after reproducing in the demo app).

@icbaker
Copy link
Collaborator

icbaker commented Dec 21, 2021

Note: We should also remove references to "Auto" and just show which track is selected.

@ojw28 Do we want to show the name even if it's a 'forced' track? It seems perhaps a user shouldn't even 'know' that a forced track is selected, since it's assumed to be required to understand the content of a given audio track.

@ojw28
Copy link
Contributor

ojw28 commented Dec 21, 2021

Do we want to show the name even if it's a 'forced' track? It seems perhaps a user shouldn't even 'know' that a forced track is selected, since it's assumed to be required to understand the content of a given audio track.

That sounds right. I think the UI should show CC as "off" or "none", but the forced track should still be selected.

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

No branches or pull requests

5 participants