-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[discussion] Caption & subtitle support #1044
Comments
I've created a PR that implements text track support for iOS & ExoPlayer in #1049. I'd appreciate a code review and testing from anyone that cares to check it out. |
Hey @cobarx sorry for the late reply to this and the Thanks! |
I've tried a couple of different props and am unable to get captions working with this stream Phone: Pixel 2 My
I have tried the following Props on the
Not sure if I am passing the props down incorrectly. Let me know if you are able to get it to work with the provided stream. |
@fdiep Oops, I was testing it by setting the text track after the video was already playing. I had forgotten to test with the text track set at the beginning. In that case, the text track gets set before the video is loaded and the text track info isn't available. I've pushed a fix to set the text track once the video loads. It's working for me now, can you test again. |
Awesome @cobarx it worked! Ill do some more testing now and update |
I've added the ability to sideload subtitles in ExoPlayer in #1063. It turns out AVPlayer doesn't allow you to sideload subtitles, so we're out of luck on iOS, they have to be loaded in the playlist. I also added info about the text tracks to onLoad, so you can see what's available. I'd appreciate testing and code review if anyone wants to take a look. |
@cobarx I have iOS side loading working in this fork based on your feature/sidecar-text-tracks branch that was merged into master 9 days ago.
Have a look at ios/RCTVideo.m. The solution uses AVMutableComposition as documented here, and is integrated directly into an AVAsset (ie. captions are not an overlay which can result in sync issues) I have not completed the logic for text track selection, but this is proof that it works. I'll finish the logic in the next 2 weeks. |
@ashnfb Wow, that's fantastic! I had no idea! Being able to use sidecar everywhere makes it a lot more useful. Looks like you are on the right approach. Do you know if there's a way to address the sync issues? Looking forward to the final version once it's ready. This is very similar to MergingMediaSource on ExoPlayer. We could even add support for merging audio tracks in at some point in the future, though I don't know how useful that is. |
@cobarx I know, we're very happy here. There currently are not any sync issues that I know of (although I'm a bit suspicious of AVAssetURL and whether it synchronous / blocking, or async). For the remaining work, am planning to copy most of your logic for Android. I will let you know how I proceed. |
Wow, super thanks, @ashnfb ! |
@ashnfb Thank you! I'm starting to take a look at it today, dunno if I have time to go through the whole thing. I'll post my notes on the PR. |
I've started working on caption & subtitle support for iOS and after looking at a number of examples, have a fairly good idea of the scope of what's needed.
Text track types
Subtitles: text for spoken audio translating the dialogue into the viewer's native language
Captions: text for spoken audio & sound effects like explosions and car horns for hearing impaired people
Text track shipping methods
Embedded: Included as part of the video file, typically using the CEA-609 format
Sidecar: Loaded from a separate file or URL, typically in the WebVTT or SRT format
Example text tracks
Likewise, you could imagine something similar with 4 audio tracks: Spanish & French dubbed, English, and English director commentary. You could also have multiple video streams: 480p, 720p, and 1080p. It makes sense to have a similar API for handling all track selections.
System settings
Both iOS & Android offer captions preferences so hearing impaired people can enable captions system wide, however Windows does not. We should honor the system setting as much as possible.
Where ever possible, we want to copy the HTML5 video API, however when it comes to tracks, the API is limited and clunky, so we can roll our own approach.
Prop for selecting text track
If a track matching the specified Type (and Value if appropriate) is unavailable, no text track will be displayed. If multiple tracks match the criteria, the first match will be used.
But why make it so complicated?
In some cases, some tracks will be incompatible with one platform but not another, so they won't be loaded and the indexes won't line up. Also, you may want to generate the menu of tracks dynamically and let the customer select them. Which brings us to another point...
Prop for receiving text track info
onTextTracksLoaded={function}
The function receives a payload that looks like:
This prop allows you to create dynamic menus for customers to select the track they want.
Prop for loading sidecar text tracks
I need to do more research on what info is included in the sidecar files and what needs to be provided before I can comment on this.
Prop for selecting audio track
I need to more research here as well, I believe we can make it similar to selectedTextTrack and call it selectedAudioTrack.
Implementation order
Sidecar text track support for iOS- not possibleNeed help with
I don't have time to implement support for the old Android or the Windows WPF & UWP players. If people want this it would be great to receive help in these areas.
Appreciate feedback from @akshaygore06 @hitaloramon @huanghanzhilian @sungjkim34 @petrbela
Edit: Fix grammar and add note about selecting the audio track. Add a disabled type.
The text was updated successfully, but these errors were encountered: