Skip to content
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

SubtitleView support GL render. #2053

Closed
peerless2012 opened this issue Jan 19, 2025 · 4 comments
Closed

SubtitleView support GL render. #2053

peerless2012 opened this issue Jan 19, 2025 · 4 comments
Assignees
Labels

Comments

@peerless2012
Copy link

[REQUIRED] Use case description

I'm trying to add libass to render ass/ssa on media3.

ASS_Image only have bitmap with alpha channe, I need to blend the color with the alpha, then put the ARGB data to bitmap, then send to cue to render.

Since ass may have many effects in seconds, thus there will be thousands of bitmap to blend, it will need huge cpu time to blend color, and huge memory to store ARGB bitmap data.

Proposed solution

The media3 only support web and canvas render.If can support GL render, I will not need to blend ass_image alpha with colour in cpu, I can copy alpha data to ALPHA_8 bitmap, then upload the bitmap to gl texture, and blend all the effect in GL shader.

This solution will cost least memory (use alpha 8 instead of ARGB 8888), and best performance (GL blend is much better than cpu).

Alternatives considered

So If SubtitleView support GL render will be great.

By the way, other subtitles should render as before, only my situation need this feature.

@icbaker
Copy link
Collaborator

icbaker commented Jan 20, 2025

The extra details in this question make me wonder if this would be better implemented as an Effect using ExoPlayer.setVideoEffects(...) rather than by a custom SubtitleView as I suggested in #2042 (comment). That would allow you to do GL operations with access to the current video size (though still no access to the displayed size, because of course it can always be resized when rendering into the UI).

@peerless2012
Copy link
Author

peerless2012 commented Jan 20, 2025

But the Effect can't access the subtilte.

Also if #2055 is support, this feature may not need anymore for me.

@icbaker
Copy link
Collaborator

icbaker commented Jan 20, 2025

But the Effect can't access the subtilte.

Are you trying to play standalone SSA files or those muxed into an MKV file or similar?

If the file is standalone, you can probably quite easily read it yourself and use it to drive your Effect implementation - there's no real need/benefit to use any of ExoPlayer's subtitle wiring at this point.

If it's muxed into an MKV file then the wiring is a bit trickier - you would likely need to get the subtitle data as it's emitted from MatroskaExtractor via a TrackOutput implementation. This would involve a custom ExtractorsFactory and a customized ForwardingExtractorOutput that lets you intercept the subtitle data. I'm afraid as I said in #2042 (comment), what you're trying to do here is fiddly and custom, so there's a limit to how much guidance we can offer you on how exactly to do each part.

@peerless2012
Copy link
Author

This feature can replace by #2055.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants