Skip to content

Add libass native decoder #2324

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

moi15moi
Copy link

This PR adds a new decoder for .ass subtitles to fix this issue: google/ExoPlayer#8435
It also partially fixes the following issue: #691

It is currently a draft because the following issues still need to be addressed:

  • Currently, it only supports .ass subtitles muxed in MKV files. It would also needs to support "raw" .ass file.
  • The way AssRenderer is added in SubtitleTranscodingTrackOutput.java and DefaultRenderersFactory.java is hacky.
  • For frame-accurate rendering, we would need this issue to be resolved: Align subtitle output with video frame timestamps (overriding explicit subtitle timestamps) #2289
  • draw_ass_rgba is too slow for 4K (3840x2160) bitmaps where the subtitle completely covers the screen. Neon optimization is needed (or maybe openmp?).

Note: We are no longer working on this PR. If anyone wants to use it as a base, feel free to improve it and open a non-draft PR.


Why should Media3 provide a native decoder using libass?

It’s practically impossible to replicate libass behavior accurately.
The first commit that introduced SSA/ASS subtitle support in Media3 is this one, made in 2017 — that was 8 years ago, and Media3 still lacks support for many elements of the ASS/SSA spec.

Here's a screenshot showing the video with and without subtitles. Implementing this in SsaParser.java is far from trivial.
image
image

Also, here’s a video that contains a .ass subtitle (hardsubbed). The subtitle is the text: "CIBLE DE LA QUÊTE".
https://github.com/user-attachments/assets/af2b54b5-baf8-41d9-bc05-f97702757402
Again, implementing all the feature in java needed just to display the subtitle accuratly is basically impossible.


Finally, note that this PR is the work of Raphael Dupuis, Sonny Uplavan, Vincent Zauhar and me.

moi15moi and others added 6 commits April 9, 2025 21:51
The fonts are sent to the renderer via the format metadata.
This news native decoder use libass to parse and render the ssa/ass subtitle.

Co-authored-by: Vincent Zauhar <[email protected]>
Co-authored-by: SonnyUplavan <[email protected]>
Co-authored-by: Raphael Dupuis <[email protected]>
Copy link

google-cla bot commented Apr 10, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@icbaker
Copy link
Collaborator

icbaker commented Apr 24, 2025

I'm afraid we are unlikely to merge this PR as the maintenance burden is likely to be too high for the benefit it brings, as I previously mentioned in this comment: google/ExoPlayer#8435 (comment)

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

Successfully merging this pull request may close these issues.

2 participants