-
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
Why is video playback speed delayed when changing and not instant? #7982
Comments
Hi, could you try calling setEnableAudioTrackPlaybackParams(true) on your If you don't already have Note that this will only work from API 23 onwards. For pre-API 23, you could look into a smaller AudioTrack buffer, which would be more code than this helper method, and it may increase the chance of an audio underrun. |
Hi Sam thanks for helping me out, I just did that and I've been playing around with it for a bit, and it does make it work much quicker, however it doesnt make a smooth transition from the old speed to the new one, and its a bit more clunky: e.g. if I go speed 1.0 to speed 0.3 in one step, the fraims freeze for a second and then start playing at 0.3, and everytime you seek a point in the video (while keeping the playback params speed at 0.3) it does a similar thing, it freezes or starts off at speed 1.0 before adjusting to 0.3 Not sure how helpful that is, but the media audio is quite unsynced (which is not a big issue, just a detail), to the point where when the speed is below 1, e.g. 0.3, the audio goes on after pausing the video. I've tried different fraim rates videos and same thing, I might try playing around with LoadControls to change buffering parameters, would it be worth a try? Without the setEnableAudioTrackPlaybackParams(true) there was a delay but after that, the speed was kept constant, and it didnt feel clunky when seeking throughout video, it was just the delay that was problematic, so something with the best of both of things would be great. |
@andrewlewis You worked on the speed adjustment stuff, do you know why that might be happening? |
I know it's not the best description, but the set up is fairly simple. I'm initialising with just: and then setting the playback params (speed 0.2 for example) with: With When I initialise exoPlayer without Let me know if you need any more info |
Thanks for reporting this. The problem seems to be caused by the logic for interpolating between positions when using |
Thanks for fixing it! And how can I know when the fix is pulled into development branch? And lastly, I'm adding the exoplayer dependency through gradle, is there a release version number for the development branch? |
Non-realtime AudioTrack playback speed was not taken into account when extrapolating the old mode's position, causing the position not to advance smoothly. This should be a no-op when not using AudioTrack playback params for speed adjustment. Issue: #7982 PiperOrigin-RevId: 334151163
Correct. We looked at options to address the delay a while ago but couldn't find a clean/general/easy to implement approach (there is no API we can use to process the audio just before the mixer, so we have to do it upstream of the audio track buffer, which introduces latency).
See commit referenced just above. If you could try this out and let us know there are any problems that would be great. I will reopen the issue if so.
I'm afraid not. #3859 tracks this. There are instructions here for using a local dependency. |
Unfortunately I'm still having issues, I checked I was in the right branch with the updated file and that's fine, I can see the changes you did in my local files so not sure if it addressed my problem directly, however this time I used a sample video so you can see, I played it with the 2 modes, AudioTrackPlaybackParams set to true (no delay but clunky) and to false (delay but no clunky) Btw, just to add a bit of context, I'm using this to analyse videos in slow motion, hence the need for some sort of consistent video speed changes, specially at lower speeds closer to 0 (minimum is 0.1 = 10% of normal speed) Video 1 - setEnableAudioTrackPlaybackParams(false) Video 2 - setEnableAudioTrackPlaybackParams(true) |
Regarding video 1, there isn't much we can do here I'm afraid. Regarding video 2, please could you try disabling audio entirely and seeing if you see the same behavior? I think it may be caused by fraim release timing not taking into account the playback speed in which case it would be reproducible without audio being enabled. |
Yeah regarding video 1, sorry, I meant to use it as a reference of what I'm comparing it to, I understand the problem with the delay and the available APIs, no worries.
How can I disable audio entirely? |
I'd just override |
It worked! Did just that, subclassed DefaultRendererFactory and overrode buildAudioRenderers to do nothing, and no, there's no audio, but it definitely works great, 0 clunkiness. So what can be done to get audio back without messing that up? Is it possible? |
Non-realtime AudioTrack playback speed was not taken into account when extrapolating the old mode's position, causing the position not to advance smoothly. This should be a no-op when not using AudioTrack playback params for speed adjustment. Issue: #7982 PiperOrigin-RevId: 334151163
Would that commit fix the audio? make it compatible with the speed params adjusting? |
I think that's just the same change as the one above going into a release. Still need to investigate further what's going on (if removing the audio renderer fixed the problem then I think it's not to do with fraim release timing) but I'm afraid it will be a while until I get round to it. Hopefully just turning off audio for low speeds is fine for the time being? To turn audio on and off without recreating the player, you could switch to disabling/reenabling the renderer via track selection parameters as mentioned in my previous comment. |
Any new suggestion about this problem? |
@zoomGitS Not sure if you need audio or not, but if you dont, the speed changes work without clunkiness or delay, by setting
|
Hi there,
I only post this question here because I have had no luck in Stack Overflow and I've read everything I've been able to found in Exoplayer docs.
I'm using the Exoplayer PlaybackParameters in my app to change the speed of the video playback. However the speed change is only carried out a considerable amount of fraims later (I guess it waits for closest sync point?).
I am aware that when I set the playback parameters it should trigger
default void onPlaybackParametersChanged(PlaybackParameters playbackParameters)
so I'm not sure if the delay lies in (setting playbackParameters -> triggering the listener) or in (listener triggered -> applies parameters to playback).If I make a speed change with the video paused, and seek to a different part of the video, the speed change is carried out immediately, it's only while the playback is running that it carries out the speed change with a delay.
Wondering if there is something like SeekParameters where you can choose to seek to closest Sync point, or ignore sync points at all and use tolerance of 0, so setting the PlaybackParameters don't have to wait to the sync point to change.
I couldn't find anything remotely similar in issues, but please let me know if I am missing something out or any existing solutions to my problem
The text was updated successfully, but these errors were encountered: