google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.75k stars 6.03k forks source link

Embedded captions not consistently displaying #10175

Closed RicFlinn closed 2 years ago

RicFlinn commented 2 years ago

I'm playing various MPEG2/TS streams using ProgressiveMediaSource. These streams have embedded CEA-608 and/or 708 captions, but not all of the streams display captions with ExoPlayer. I've ran them through other media players and verified they display captions.

I'm not attempting to modify the caption display at all, just enable them with default settings. I'm using a track selector:

DefaultTrackSelector trackSelector = new DefaultTrackSelector(this);
trackSelector.setParameters(
        trackSelector.buildUponParameters()
                .setPreferredTextLanguage("en")
                .setSelectUndeterminedTextLanguage(true)
);

Works great for some streams, and for DASH with TTML subtitles, but not for all streams with embedded 708 captions. Do I need more steps to enable CEA captioning?

I'm using ExoPlayer v 2.16.1; I tried 2.17.1 as well.

icbaker commented 2 years ago

This is likely due to the track not being detected by the TsExtractor. If you add an EventLogger with your TrackSelector (or use our demo app) you will see the tracks that have been found logged to logcat.

You may find that the files that ExoPlayer doesn't find subtitle tracks in aren't declaring the tracks in a way that ExoPlayer can detect. We used to create a subtitle track for all TS files due to this ambiguity, but stopped in https://github.com/google/ExoPlayer/commit/6d0696a3c84f05889e7a9a54025f9ec8cf81c733 (included in 2.12.0). As explained in the release notes change in that commit, you can enable the output by passing a non-empty list of Format objects when constructing a DefaultTsPayloadReaderFactory, probably a list like:

ImmutableList.of(
    Format.Builder()
        .setSampleMimeType(MimeTypes.APPLICATION_CEA608)
        .build())

If that doesn't resolve the problem, please provide the media samples you're not seeing subtitles for so we can investigate further. Please either upload them here or send to dev.exoplayer@gmail.com using a subject in the format Issue #10175. Please also update this issue to indicate you’ve done this.

RicFlinn commented 2 years ago

Thanks @icbaker, it's just as you suspected. Using a custom DefaultTsPayloadReaderFactory seems to have resolved the issue in all of the streams I've tested so far. Calling this one done.