TheWidlarzGroup / react-native-video

A <Video /> component for react-native
http://thewidlarzgroup.github.io/react-native-video/
MIT License
7.14k stars 2.88k forks source link

[BUG]: 608/708 captions in HLS source not recognized by the player #3766

Closed TylerBKrumme closed 2 months ago

TylerBKrumme commented 4 months ago

Version

^6.0.0-beta.8

What platforms are you having the problem on?

Android

Architecture

Old architecture

What happened?

608/708 captions within an HLS source aren't recognized by the player, onTextTracks never triggers.

Reproduction

repository link

Reproduction

Ran on an android emulator on a windows PC.

Step to reproduce this bug are: Set up a basic app with the player, with HLS sources enabled. Set source to an HLS playlist with embedded 608/708 captions 608/708 tracks are never found, onTextTracks never triggers

freeboub commented 4 months ago

@TylerBKrumme any sample video you can share ?

TylerBKrumme commented 4 months ago

@freeboub Here's a sample source: https://api.v3.invintus.com/StreamURI/hls/1000000000/2024051020/media.m3u8

freeboub commented 4 months ago

Thank you for the sample ! I tested with sample exoplayer app I don't see any text tracks also. I think the issue comes from the video..

Here is the logcat output of the sample which displaying all tracks. I don't see any CEA 608 / 708 tracks..

05-14 09:24:47.570 23389 23389 D EventLogger: tracks [eventTime=0.84, mediaPos=0.00, window=0, period=0
05-14 09:24:47.570 23389 23389 D EventLogger:   group [
05-14 09:24:47.570 23389 23389 D EventLogger:     [X] Track:0, id=0, mimeType=video/avc, container=application/x-mpegURL, bitrate=3000663, codecs=avc1.640028, res=1920x1080, fps=29.97, supported=YES
05-14 09:24:47.570 23389 23389 D EventLogger:     [ ] Track:1, id=1, mimeType=video/avc, container=application/x-mpegURL, bitrate=520475, codecs=avc1.640028, res=1920x1080, roleFlags=[trick-play], supported=YES
05-14 09:24:47.571 23389 23389 D EventLogger:     [X] Track:2, id=2, mimeType=video/avc, container=application/x-mpegURL, bitrate=1913443, codecs=avc1.4d4028, res=1280x720, fps=29.97, supported=YES
05-14 09:24:47.571 23389 23389 D EventLogger:     [ ] Track:3, id=3, mimeType=video/avc, container=application/x-mpegURL, bitrate=169897, codecs=avc1.4d4028, res=1280x720, roleFlags=[trick-play], supported=YES
05-14 09:24:47.571 23389 23389 D EventLogger:     [X] Track:4, id=4, mimeType=video/avc, container=application/x-mpegURL, bitrate=1344595, codecs=avc1.4d401f, res=854x480, fps=29.97, supported=YES
05-14 09:24:47.571 23389 23389 D EventLogger:     [ ] Track:5, id=5, mimeType=video/avc, container=application/x-mpegURL, bitrate=117475, codecs=avc1.4d401f, res=854x480, roleFlags=[trick-play], supported=YES
05-14 09:24:47.572 23389 23389 D EventLogger:     [X] Track:6, id=6, mimeType=video/avc, container=application/x-mpegURL, bitrate=762307, codecs=avc1.4d401e, res=640x360, fps=29.97, supported=YES
05-14 09:24:47.572 23389 23389 D EventLogger:     [ ] Track:7, id=7, mimeType=video/avc, container=application/x-mpegURL, bitrate=72682, codecs=avc1.4d401e, res=640x360, roleFlags=[trick-play], supported=YES
05-14 09:24:47.572 23389 23389 D EventLogger:     [X] Track:8, id=8, mimeType=video/avc, container=application/x-mpegURL, bitrate=487655, codecs=avc1.4d400c, res=284x160, fps=29.97, supported=YES
05-14 09:24:47.572 23389 23389 D EventLogger:     [ ] Track:9, id=9, mimeType=video/avc, container=application/x-mpegURL, bitrate=37265, codecs=avc1.4d400c, res=284x160, roleFlags=[trick-play], supported=YES
05-14 09:24:47.572 23389 23389 D EventLogger:   ]
05-14 09:24:47.572 23389 23389 D EventLogger:   group [
05-14 09:24:47.572 23389 23389 D EventLogger:     [X] Track:0, id=0, mimeType=audio/mp4a-latm, container=application/x-mpegURL, codecs=mp4a.40.2, supported=YES
05-14 09:24:47.572 23389 23389 D EventLogger:   ]
05-14 09:24:47.572 23389 23389 D EventLogger:   group [
05-14 09:24:47.572 23389 23389 D EventLogger:     [X] Track:0, id=ID3, mimeType=application/id3, supported=YES
05-14 09:24:47.572 23389 23389 D EventLogger:   ]
05-14 09:24:47.572 23389 23389 D EventLogger:   Metadata [
05-14 09:24:47.572 23389 23389 D EventLogger:     HlsTrackMetadataEntry
05-14 09:24:47.572 23389 23389 D EventLogger:   ]
05-14 09:24:47.572 23389 23389 D EventLogger: ]
freeboub commented 4 months ago

I will close the issue as it is either a stream issue or an exoplayer issue. (cannot be fixed in this repo) Notice that I was able to display subtitles with bitmovin sample player: https://bitmovin.com/demos/stream-test?format=hls&manifest=https%3A%2F%2Fapi.v3.invintus.com%2FStreamURI%2Fhls%2F1000000000%2F2024051020%2Fmedia.m3u8

May need to be tripple check and investigated with exoplayer sample

TylerBKrumme commented 3 months ago

@freeboub Hey, we were able to find the solution to this, .setAllowChunklessPreparation(false) exoplayer/hls#disabling-chunkless to false on the HLS Media Source Factory

By editing react-native-video/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java in node_modules, we were able to register & display our 608/708 captions.

case CONTENT_TYPE_HLS:
    if (!BuildConfig.USE_EXOPLAYER_HLS) {
        DebugLog.e("Exo Player Exception", "HLS is not enabled!");
        throw new IllegalStateException("HLS is not enabled!");
    }

    mediaSourceFactory = new HlsMediaSource.Factory(
        mediaDataSourceFactory
    ).setAllowChunklessPreparation(false);
    break;

A prop or build opt that can be used to set .setAllowChunklessPreparation would fix this issue.

freeboub commented 3 months ago

I propose to add a new prop: source.textTracksAllowChunklessPreparation to enable this feature

freeboub commented 3 months ago

I just created a pull request to integrate the feature: https://github.com/TheWidlarzGroup/react-native-video/pull/3882. Can you please test it ?

TylerBKrumme commented 3 months ago

@freeboub Hey, Just got a chance to test it and it doesn't appear to work. Setting source like:

source={{ 
  uri: "https://api.v3.invintus.com/StreamURI/hls/1000000000/2024051020/media.m3u8",
  textTracksAllowChunklessPreparation: false,
}}
freeboub commented 3 months ago

Reopen, let me double check

freeboub commented 3 months ago

@TylerBKrumme Finnally review the behavior, Can you test this PR please ? https://github.com/TheWidlarzGroup/react-native-video/pull/3913

freeboub commented 2 months ago

Fix merged for 6.3.0