-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Question about onRenderedFirstFrame #2533
Comments
onRenderedFirstFrame is what you need. What exactly is a "hidden surface", and how are you hiding it and making it visible? |
It's actually a TextureView, not a surface, and I'm setting its visibility from VISIBLE to INVISIBLE. I basically have two TextureViews playing two videos, and I only want to show the second TextureView once the second video is rendering onto it. If I show it when I get the onRenderedFirstFrame() callback, there's still a tiny delay between it being shown and the video rendering continuously. I really appreciate your help with this. :) |
To help with debugging, I'd suggest you try posting a delayed message/runnable in Is there still an issue when the If you're not seeing the problem when you add the delay, how far can you reduce the delay until the problem re-appears? If delaying 16ms or 32ms (i.e. one or two VSYNCs) reliably avoids the problem, then pragmatically I'd suggest simply doing that. If it can be proven that there's potentially a 1 or 2 VSYNC delay for the frame to be made visible, we could potentially consider adding such a delay prior to firing |
Okay, so here are my findings:
Our streams have a keyframe every 0.52 seconds, and Exo waits for the first keyframe before rendering, right? Is that being taken into account when |
|
There's a consistent 200-300ms delay between |
Not really. Sorry! Does this happen on all devices? Is it possible for you to provide a minimal change to the ExoPlayer demo app that allows us to easily reproduce the issue? |
@ojw28 Quick q: once the player is in Because there is a delay with my HLS media, and I cannot find the cause of it. |
We always render the first frame as soon as possible. For HLS it's possible that a segment doesn't have a key-frame near the start. It the chunk spans time [5-10], the user seeks to t=6 and the first key-frame in the chunk is at t=9, then we'll request the [5-10] chunk and find that the first frame we can actually display is the key-frame at t=9. Hence we'll display this frame, then not render any more frames until audio actually reaches t=9, then play audio and video together from that point. This is not a problem if key-frames are positioned near the start of each segment (which I think is a recommendation somewhere in one of Apple's docs). In both DASH and SmoothStreaming it's required (in practice at least) that every segment begin with a key-frame. |
Ah okay, so that explains why audio plays with no delay whatsoever, but the video doesn't. Is there a way for me to get a callback or find out when video playback reached the keyframe and is continuing together with audio? I want to display the surface when the video is actually playing, and neither I really appreciate your continued support on this. :) |
@ojw28 Sorry mate, any update/thought/views on this? |
Not really, sorry. You'll probably have to do some more digging yourself. Maybe if we were to report the presentation timestamp of the rendered frame via onRenderedFirstFrame, you'd be able to compare that against the current playback position. When the playback position starts to exceed the presentation timestamp you'll know that frames are being rendered regularly. You could try making that change; I don't see any reason not to accept a pull request doing that if it helps. It's also possible that when the first frame gets rendered may change slightly as fallout from some changes being made related to #2582. It's somewhat unclear to me how they'll affect the issue described here. Those changes will likely land in the next few weeks, so might be worth re-evaluating this with the latest |
Hey guys!
More of a question than a bug. I have a player and a hidden surface. I want to show the surface the second the player is actually rendering onto it continuously.
I looked at EventListener's onPlaybackStateChanged(), and I get a callback when the player is ready, but it being ready and it rendering are two different things - it needs a keyframe to start rendering, which might be 200 milliseconds away.
Next, I looked at VideoListener's onRenderedFirstFrame() - aptly named, I figured that's what I need. Alas, there's still a visible delay between my getting that callback, and the video actually rendering on my surface.
Edit: Same with VideoRendererEventListener's onRenderedFirstFrame().
I wonder if there's a callback I am not aware of, or if there's any way of sidestepping that tiny delay I'm seeing.
Using v2.2.0, HlsMediaSource, API 22 on a Samsung SM-J200M.
Thanks!
The text was updated successfully, but these errors were encountered: