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
Change playback rate of video track #1216
Comments
So, for the sake of simplicity let us say you have only a Video track. In that case, of course, the playback speed of video is linked to real time (since there is no audio). I am tempted to think that the provided gist is a bit of an overkill. I would try to use an implementation of MediaClock that suits your needs. Something like the StandaloneMediaClock but with your adaptations to support the desired playback speed. You shouldn't find yourself in need of playback implementation modifications. Keep me updated if you feel you have met an Exoplayer limitation. |
OK, thanks. It seems #571 is related too then. |
Does it work well? Have you tried just using your own MediaClock implementation instead of modifying the renderer? |
It seems reasonable. I am not sure it would work with buffering mid video and/or seeking, but I will try to improve it. Is that gist not what you meant by "using your own MediaClock implementation"? The only modification to the renderer I made was to give it it's own MediaClock. I took inspiration from LibopusAudioTrackRenderer. |
Yes, I had just read the class name and not walked through the code. Sorry about it. |
Hey @jmgirven, Great effort for fast-forward video and it does work great. I'm talking about HLS, if that matters. Thanks ! |
Actually, when using a multiplier bigger than 2 it make the video freeze, any idea why ? |
Mobile devices are simply not able to decode video at arbitrarily high speeds (note that network speed may also become an issue if you're streaming the content, since you're basically doubling the bitrate requirements). It's likely that if you use a lower quality video format, you'll be able to increase the multiplier further. |
@ojw28 Thank you very much for the quick response ! So is there nothing to do with that ? I do stream the video from network at reasonably high resolution.. I wouldn't mind keep the player buffering until it continue to load enough data and then play it again. Is there any solution to this ? |
I think you're just exceeding the capabilities of the device. There are more complicated schemes where you actually serve sped up streams from the server, and then have the client switch to the correct speed stream according to the setting. That's pretty much the only option if you want to be able to do this without increasing network/decoder requirements as you increase the speed multiplier. We don't support such schemes directly, but it's probably not too hard to do so. It's probably more work on the serving side. |
@eshkoliGilad Are you sure the [https://gist.github.com/jmgirven/4e0ba2c7d584c8695549](First effort) can work? |
I would like to reduce the playback rate of a video to 50%, or increase it to 200%. #26 is a similar thread, but contrary to what they are trying to do, I don't really care about the audio. One of the first comments is:
My answer is without audio. Does this make a significant different to the complexity of the answer?
I am primarily interested in locally stored mp4 files. I am looking to support Android 16 and above.
It sounds like the playback speed of the video is tied to the speed of the audio. Is that always true? I have tried using this gist to slow the audio, but as @jedhoffmann says in his comment on #26, he hasn't factored in video. I find that with video and slow motion, the playback becomes very jerky (far more than should be expected from having fewer frames rendered to the screen per second).
This sample does suggest it accounts for video (albeit based on an older version of exoplayer), but the main contribution of
mCurrentSpeed
to the code is to modify thejoiningDeadlineUs
. Is this what I am missing to get smooth playback in slow motion? Naively, it sounded like an optimisation rather that being key.The text was updated successfully, but these errors were encountered: