anilbeesetti / nextplayer

An Android native video player
GNU General Public License v3.0
1.26k stars 58 forks source link

[FEATURE] Support refresh rate change #960

Open markg85 opened 1 month ago

markg85 commented 1 month ago

Hi,

In Android you can request a frame rate change: https://developer.android.com/media/optimize/performance/frame-rate Currently NextPlayer isn't doing this, my framerate is fixed at 60.

For optimal video playback it's ideal to match the display framerate to the video framerate. You need to set this on the Surface object (or a derivative of it) with setFrameRate

I did have a look in the code and it seems you should be doing that in PlayerActivity.kt around the lines where you attach a view to the player. But i could not find how you'd get the frame rate from a file to even set. You probably know this right on the top of your head :)

Best regards, Mark

markg85 commented 1 month ago

A little more information.

If one uses the android MediaCodec (so not the ffmpeg ones) then you can let android do most of this. You can set setVideoChangeFrameRateStrategy on the ExoPlayer object to one of the enum values. I'd just set it to CHANGE_FRAME_RATE_ALWAYS.

For the ffmpeg side of things you'd have to first get the framerate from the source and then set that framerate through a different code path on the player Surface object.

I would have tried this in code but my compile is having serious issues and different issues every time (mind boggling.. i hate the android build stack, so full of many mysterious failure points).