androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
Apache License 2.0
1.37k stars 322 forks source link

ExoPlayer playback is stuttering #1532

Open Rgoogle opened 4 days ago

Rgoogle commented 4 days ago

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

tonihei commented 3 days ago

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: