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

Embedded Video Subtitle #2095

Open
langaliamayank opened this issue Jan 31, 2025 · 0 comments
Open

Embedded Video Subtitle #2095

langaliamayank opened this issue Jan 31, 2025 · 0 comments

Comments

@langaliamayank
Copy link

langaliamayank commented Jan 31, 2025

Media3 Exoplayer Not showing Embedded Video Subtitle for HLS(M3U8) Stream

https://flux1.csidigital.net/GPU4/hls_live/INSP_HD/playlist.m3u8
For getting render type = 5 - TRACK_TYPE_METADATA
mimetype - application/id3

I checked the above streaming URL in VLC player and The OPlayer.
We are getting subtitles but when I tried with Exo player media3 v1.4.1 not work.

DefaultTrackSelector.Parameters parameters = mTrackSelector.getParameters();
DefaultTrackSelector.Parameters.Builder builder = parameters.buildUpon();
final MappingTrackSelector.MappedTrackInfo mappedTrackInfo = mTrackSelector.getCurrentMappedTrackInfo();
if (mappedTrackInfo == null) {
return;
}
for (int i = 0; i < mappedTrackInfo.getRendererCount(); i++) {
if (mappedTrackInfo.getRendererType(i) == C.TRACK_TYPE_TEXT) {
builder
.clearOverridesOfType(i)
.setRendererDisabled(C.TRACK_TYPE_VIDEO, false)
.setSelectUndeterminedTextLanguage(true)
.setPreferredTextRoleFlags(C.ROLE_FLAG_CAPTION);

            TrackGroupArray trackGroupArray = mappedTrackInfo.getTrackGroups(i);
            for (int trackIndex = 0; trackIndex < trackGroupArray.length; ++trackIndex) {
                Format format = trackGroupArray.get(trackIndex).getFormat(0);
                if (format.id != null && (format.sampleMimeType.equalsIgnoreCase("application/cea-608")
                        || format.sampleMimeType.equalsIgnoreCase("application/cea-708"))) {
                    builder.addOverride(new TrackSelectionOverride(trackGroupArray.get(trackIndex), 0));
                } else {
                    builder.addOverride(new TrackSelectionOverride(trackGroupArray.get(trackIndex), 0));
                }

            }


            mTrackSelector.setParameters(builder);
        }
    }

public int getTrackCountSubtitle() {
if (mTrackSelector != null) {
final MappingTrackSelector.MappedTrackInfo mappedTrackInfo = mTrackSelector.getCurrentMappedTrackInfo();
if (mappedTrackInfo != null) {
for (int rendererIndex = 0; rendererIndex < mappedTrackInfo.getRendererCount(); rendererIndex++) {
Logger.e("getTrackCountSubtitle" + mappedTrackInfo.getRendererType(rendererIndex));
if (mappedTrackInfo.getRendererType(rendererIndex) == C.TRACK_TYPE_TEXT) {
final TrackGroupArray trackGroups = mappedTrackInfo.getTrackGroups(rendererIndex);
return trackGroups.length;
}
}
}
}
return 0;
}

getTrackCountSubtitle method return 0 because render type return 5 not 3.

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

1 participant