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

ExoPlayer playback is stuttering #1532

Open
1 task
Rgoogle opened this issue Jul 4, 2024 · 1 comment
Open
1 task

ExoPlayer playback is stuttering #1532

Rgoogle opened this issue Jul 4, 2024 · 1 comment
Assignees

Comments

@Rgoogle
Copy link

Rgoogle commented Jul 4, 2024

Version

Media3 1.3.1

More version details

I'm experiencing a strange issue. I'm playing a video on my Android 11 phone, and everything is normal. When I use USB screen mirroring, it also plays smoothly. However, when I connect to an HDMI output and project the video to a TV, it stutters every 10 seconds. I've tried using LoadControl to control the playback, but it doesn't seem to make a difference. The stuttering occurs every 10 seconds. If there's an issue with the code, why does it play normally on the phone screen and USB screen mirroring, but not when connected to an HDMI output? My device is an Android 11 system with an HDMI interface. I've tried many solutions, but I still can't find the problem. Performance analysis shows that the memory usage is around 280M, and the CPU usage is around 24% at its peak, with a relatively flat waveform. However, the video still stutters when projected to a TV using HDMI. It's possible that this isn't an ExoPlayer issue.

But when I use the Android native MediaPlayer to play the video, everything is normal. As soon as I use ExoPlayer to play the video, the issue occurs. Physically, how can I modify the code to fix this issue, which seems to occur every 10 seconds?

implementation("androidx.media3:media3-exoplayer:1.3.1") this is my dependency

Devices that reproduce the issue

Android 11 . no productor . me

Devices that do not reproduce the issue

all phone

Reproducible in the demo app?

Yes

Reproduction steps

  1. open app and play video

Expected result

no stuttering

Actual result

stuttering

Media

when I connect to an HDMI output and project the video to a TV, it stutters every 10 seconds.

Bug Report

  • You will email the zip file produced by adb bugreport to [email protected] after filing this issue.
@tonihei
Copy link
Collaborator

tonihei commented Jul 4, 2024

It might be that the device output logic is making assumptions about the frame rate and decides to release frames when it thinks they should be released based on frame rate, not when ExoPlayer asks it to release frames. We've seen such behavior before and it usually means that the speed at which buffers are consumed is not at the same at which they are produced. And at some point the codec not be able to produce new buffers if all the pending buffers are not yet released, creating a stuttering effect.

Things to try out:

  • Check for settings on the TV itself. There might be a kind of "frame rate adjustment", "smoother playback" mode or similar that causes this additional adjustment.
  • If supported by the TV, you can try to enable tunneling. This usually sets the output path in a different mode where the decoding and frame release logic is entirely handled by the TV itself. It might be more efficient even, but we are aware of many device-specific quirks with tunneling, that's why it's not enabled by default.
  • To debug further, e.g. to confirm my hypothesis above, you'd need to log details about the frame release pattern to see what is happening. You could add log lines [around here], logging the frame release action, the buffer timestamps, release timestamps and the getEarlyUs() value. This should provide a relative complete picture about where the stuttering itself is coming from. It doesn't solve the problem though. There might be ways to set different frame rate hints to the codec or otherwise use different configurations of the media itself, but this becomes increasingly hacky.

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

No branches or pull requests

2 participants