这是indexloc提供的服务,不要输入任何密码
Skip to content

Align subtitle output with video frame timestamps (overriding explicit subtitle timestamps) #2289

@moi15moi

Description

@moi15moi

Version

Media3 main branch

More version details

I used the main branch, but I added the video in a commit. Here is my branch: https://github.com/moi15moi/media/tree/Bug-report

Devices that reproduce the issue

Motorola Moto G Stylus (2023) - Android 14

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

  1. Launch the demo app in noDecoderExtensionsRelease.
  2. Start recording your screen.
  3. Launch the test_video_problem.mkv.
  4. Stop the video.
  5. With mpv, check out the video recorded. Use , and . to go frame per frame. In media3, you will see that the subtitle doesn't exactly start at the frame 10 and it stop been showed at the frame 21. But, in mpv, you will see that it exactly start at the frame 10 and stop at the frame 20.

Expected result

The subtitle should start being shown at frame 10, remain visible until frame 20, and no longer be shown at frame 21.

Actual result

At frame 10, the subtitle is still not visible.
Image

Then, it appears (even if we are already on the frame 10)
Image

At frame 21, the subtitle is still visible (which it shouldn’t be).
Image

Finally, the subtitle disappears at frame 21.
Image

Here is a video where I recorded my screen while playing test_video_problem.mkv (all my previous screenshot are from this video): https://github.com/user-attachments/assets/87f36fef-44ec-43b9-af6a-8a332d0813d8

Edit: This probably happen because TextRenderer.render() is not called on each renderer frame timestamps. I added Log.d("DebugRender", "Time: " +getPresentationTimeUs(positionUs) / 1000 + " ms"); at the beginning of render and I got this:

Time: 0 ms
Time: 0 ms
Time: 0 ms
Time: 0 ms
Time: 6 ms
Time: 15 ms
Time: 25 ms
Time: 36 ms
Time: 46 ms
Time: 56 ms
Time: 66 ms
Time: 77 ms
Time: 87 ms
Time: 96 ms
Time: 107 ms
Time: 117 ms
Time: 127 ms
Time: 138 ms
Time: 147 ms
...

For my video (test_video_problem.mkv), it should be called with these:

Time: 0 ms
Time: 42 ms
Time: 83 ms
Time: 125 ms
Time: 167 ms

From what I can see, this is the workflow to call TextRenderer.render():

  1. ExoPlayerImplInternal.handleMessage()
  2. ExoPlayerImplInternal.doSomeWork()
  3. RendererHolder.render()
  4. TextRenderer.render()

It doesn't seems possible to use the frame timestamps to call TextRenderer.render(), so I'm not really sure how we could fix this issue.

Media

You can find the video test_video_problem.mkv in my branch: https://github.com/moi15moi/media/tree/Bug-report

Here is the exact link: https://github.com/moi15moi/media/blob/Bug-report/demos/main/src/main/assets/test_video_problem.mkv

Bug Report

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions