question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to enable subtitles on dash stream?

See original GitHub issue

ExoPlayer 2.9.1 I run exoPlayer on AndroidTV with leanback support.

my configuration

ExoPlayerFactory.newSimpleInstance(
            context,
            DefaultRenderersFactory(context),
            trackSelector,
            DefaultLoadControl(),
            defaultDrmSessionManager
        )

and I switch tracks using below method:

    fun setTrack(model: FormatUiModel) {
        val newParams = trackSelector.buildUponParameters()

        when (model.formatType) {
            FormatUiModel.Type.VIDEO -> {
                newParams.setMaxVideoBitrate(model.format.bitrate)
                newParams.setMaxVideoSize(model.format.width, model.format.height)
            }
            FormatUiModel.Type.AUDIO -> {
                newParams.setPreferredAudioLanguage(model.format.language)
            }
            FormatUiModel.Type.TEXT -> {
                newParams.setRendererDisabled(C.TRACK_TYPE_VIDEO, false)
                newParams.setPreferredTextLanguage(model.format.language)
            }
        }
        trackSelector.parameters = newParams.build()
    }

it works fine for video and audio. But subtitles/text are not displaying but I can see that text track is selected.

All available tracks:

com.tv.uat D/ExoPlayerAdapter: getFormatsFromTrackGroups 0, 0 Format(video=1001000, null, video/mp4, video/avc, avc1.640028, 1001000, null, [1024, 576, 25.0], [-1, -1])
com.tv.uat D/ExoPlayerAdapter: getFormatsFromTrackGroups 0, 1 Format(video=2001000, null, video/mp4, video/avc, avc1.640028, 2001000, null, [1280, 720, 25.0], [-1, -1])
com.tv.uat D/ExoPlayerAdapter: getFormatsFromTrackGroups 0, 2 Format(video=5001000, null, video/mp4, video/avc, avc1.640028, 5001000, null, [1920, 1080, 25.0], [-1, -1])
com.tv.uat D/ExoPlayerAdapter: getFormatsFromTrackGroups 0, 0 Format(audio_eng=128000, null, audio/mp4, audio/mp4a-latm, mp4a.40.2, 128000, en, [-1, -1, -1.0], [2, 48000])
com.tv.uat D/ExoPlayerAdapter: getFormatsFromTrackGroups 1, 0 Format(audio_lav=128000, null, audio/mp4, audio/mp4a-latm, mp4a.40.2, 128000, lv, [-1, -1, -1.0], [2, 48000])
com.tv.uat D/ExoPlayerAdapter: getFormatsFromTrackGroups 2, 0 Format(audio_lit=128000, null, audio/mp4, audio/mp4a-latm, mp4a.40.2, 128000, lt, [-1, -1, -1.0], [2, 48000])
com.tv.uat D/ExoPlayerAdapter: getFormatsFromTrackGroups 0, 0 Format(textstream_est=1000, null, application/mp4, application/ttml+xml, stpp, 1000, et, [-1, -1, -1.0], [-1, -1])
com.tv.uat D/ExoPlayerAdapter: getFormatsFromTrackGroups 1, 0 Format(textstream_lav=1000, null, application/mp4, application/ttml+xml, stpp, 1000, lv, [-1, -1, -1.0], [-1, -1])
com.tv.uat D/ExoPlayerAdapter: getFormatsFromTrackGroups 2, 0 Format(textstream_rus=1000, null, application/mp4, application/ttml+xml, stpp, 1000, ru, [-1, -1, -1.0], [-1, -1])

Can someone shows how to implement selecting text tracks? Or point me to right doc.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ojw28commented, Oct 16, 2019

Are you using our PlayerView UI component?

It takes care of rendering the subtitles if you’re using it. If you’re not using it then you need to add something as a text output to the player (player.addTextOutput), which will receive the subtitles. You’ll then need to render them. You can use SubtitleView for this, if you don’t want to use the full PlayerView. You can add a SubtitleView` as a text output directly on the player.

0reactions
luna-vulpocommented, Oct 16, 2019

nop. I use leanback for android tv. Very similar as in this example: https://github.com/googlearchive/leanback-showcase

I will falow your advide. thx.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Subtitles - Unified Streaming
For DASH and Smooth output, by default the length of the subtitles segments is equal to the length of the fragments in the...
Read more >
FOSDEM 2016 - Adding subtitles to the dash.js player
In this presentation, Solène Buet will detail how W3C TTML subtitles can be used with MPEG DASH streaming, and how it was tested...
Read more >
Multiple Language Timed Text Sample - dash.js
Example showing content with multiple timed text tracks. The current texttrack settings can be saved in the local storage to be reused on...
Read more >
HOW TO ADD SUBTITLES TO TWITCH STREAMS ... - YouTube
Today I show how to add closed captions & subtitles to your Twitch streams using a Twitch extension. Closed Captions Extension: ...
Read more >
Dash manifest generation with subtitles - Stack Overflow
I believe it should be quite easy, simply putting subtitles' url somewhere with special tags. I've tried to find some information around about ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found