RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
235 stars 28 forks source link

Android Pause timing is not precise #448

Closed patrikmrazek closed 3 years ago

patrikmrazek commented 4 years ago

Describe the bug Video on Android is not paused immediatelly after calling Pause() on a player, but gets actually paused couple of frames later.

I have a VR app that is supposed to work on both Windows (VIVE) and Android (Oculus Quest). I need to pause my video at the exact time. I check each frame if the video time that the video should be paused at has already passed. If so, I call VideoPlayer.Pause(); This works great on Windows, but on Android the video gets paused aprox. about 10 frames later than it is supposed to. I tried both ExoPlayer and MediaPlayer engine. It happens on both, but seems to be a bit better on MediaPlayer.

Your Setup (please complete the following information):

To Reproduce

  1. Play any video in AVPro on Android. Select a time to pause a video at.
  2. Check each frame if the time to pause the video has already passed in the video with VideoPlayer.Control.GetCurrentTimeMs()
  3. If the time has already passed pause the video.

Logs If applicable, add error logs to help explain your problem.

Screenshots If applicable, add screenshots to help explain your problem.

Videos If applicable, add a copy of your video or the URL

Please DO NOT LINK / ATTACH YOUR PROJECT FILES HERE

Instead email the link to us unitysupport@renderheads.com

Ste-RH commented 4 years ago

So you are seeing the pause happen some 200ms past your desired pause-point?

How far over your desired time are you seeing the return from GetCurrentTimeMs() be?

I wonder if your use case is better in AVPro v2 beta...is this something you could test?

patrikmrazek commented 4 years ago

I ment game frames, which on Oculus is about 140ms, but I have done a couple more tests today to provide more details. I will also try v2 beta a bit later and come with results.

The video gets paused usually 20ms later than desired, due to GetCurrentTimeMs(). If for example I pause video at a game frame which is 3000ms in the video, the video continues to 3020ms due to data from GetCurrentTimeMs(). That would be fine. But there is something wrong, because the behaviour on Win and Android is different.

I have the same video and want to pause it at the same moment on both platforms. Each game frame I check GetCurrentTimeMs() and if the video time is closer to the desired pause point than it should be the next game frame I pause the video. On Win, this works great. But to achieve the same real video pause frame on Android I need to call Pause() about 4 game frames earlier. But sometimes this is still not enough and the video still gets paused a bit later than desired. Things are worse on ExoPlayer. For me it seems like GetCurrentTimeMs() gives unprecise data on Android.

AndrewRH commented 4 years ago

Hi @patrikmrazek

Are you using the OES mode on Android? That could have an affect on frame latency..

patrikmrazek commented 4 years ago

Hey @AndrewRH, no we are not using OES mode.

Ste-RH commented 4 years ago

Could you provide the video you are seeing this issue with? You can send it to unitysupport@renderheads.com

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been automatically closed because it has not had recent activity. If you wish to continue this issue, then please create a new issue as we do not monitor closed issues.