Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rendering Closed Captions for HLS streams on Android

I'm working on a native Android application that streams HLS video. I'm trying to get CEA-608 closed caption data to display, but I'm running into a problem.

Methodology: I'm running on a Jelly bean device (API 4.1+), which supports closed captions and HLS playback (http://developer.android.com/about/versions/android-4.1.html#Multimedia).

Test Feed: I'm testing using the Apple sample HLS bip-bop feed that contains captions data (https://devimages.apple.com.edgekey.net/resources/http-streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8)

Grabbing Caption Data: As per the Android documentation, I'm attempting to get the caption track by calling:

"MediaPlayer.getTrackInfo()"

Problem: The player crashes when I execute the getTrackInfo() line, with the following output in LogCat:

E/AndroidRuntime(7311): FATAL EXCEPTION: main E/AndroidRuntime(7311): java.lang.RuntimeException: failure code: -38

Questions: 1) Is closed caption rendering from in-stream caption data on an HLS feed supported in native Android apps? 2) If not, are there alternatives? 3) The documentation in the link above (quoted below) indicates that in-stream captions are supported on MP4 or 3GPP media sources. Does that necessarily exclude HLS (which I believe is MPEG-2 based) from working?

The MediaPlayer now handles both in-band and out-of-band text tracks. In-band text tracks come as a text track within an MP4 or 3GPP media source. Out-of-band text tracks can be added as an external text source via addTimedTextSource() method. After all external text track sources are added, getTrackInfo() should be called to get the refreshed list of all available tracks in a data source.

Thanks for any help you can offer!

like image 336
Bob Cowherd Avatar asked Feb 07 '13 00:02

Bob Cowherd


2 Answers

We went thru exactly same exercise. MediaPlayer on Android doesn't seem to support CEA-608 embedded in HLS. OnTimedTextListener was never called when media player (MP) was playing. On trying to call getTrackInfo() when MP was playing resulted in crash as you mentioned.

May be Android MP can decode only included SRT in MP4.

Alternative would be to use external timed text track but in live streaming environment, it is going to be difficult.

like image 56
Azul Avatar answered Oct 06 '22 21:10

Azul


The question is quite old, but some people still might face the problem.

ExoPlayer tries to solve the issue as an Android version independent general multimedia library.

It currently supports CEA-608, SubRip, TTML, TX3g and WebVtt subtitles. Of course not fully all the standards, but a useful part of them.

like image 42
Habib Avatar answered Oct 06 '22 21:10

Habib