Skip to content
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

Closed
jmgirven opened this issue Feb 1, 2016 · 13 comments
Closed

Change playback rate of video track #1216

jmgirven opened this issue Feb 1, 2016 · 13 comments
Assignees
Labels

Comments

@jmgirven
Copy link

jmgirven commented Feb 1, 2016

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:

To clarify, do you mean with audio (sped up but corrected to still be at the correct pitch) or without?

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 the joiningDeadlineUs. Is this what I am missing to get smooth playback in slow motion? Naively, it sounded like an optimisation rather that being key.

@AquilesCanta AquilesCanta self-assigned this Feb 1, 2016
@AquilesCanta
Copy link
Contributor

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.

@jmgirven
Copy link
Author

jmgirven commented Feb 1, 2016

OK, thanks. It seems #571 is related too then.

@jmgirven
Copy link
Author

jmgirven commented Feb 1, 2016

First effort

@AquilesCanta
Copy link
Contributor

Does it work well? Have you tried just using your own MediaClock implementation instead of modifying the renderer?

@jmgirven
Copy link
Author

jmgirven commented Feb 2, 2016

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.

@AquilesCanta
Copy link
Contributor

Yes, I had just read the class name and not walked through the code. Sorry about it.

@eshkoliGilad
Copy link

eshkoliGilad commented Jun 26, 2016

Hey @jmgirven, Great effort for fast-forward video and it does work great.
Any idea on how to rewind a video ? putting a negative value does not rewind it, the video get stuck until forwarding again to the same position.

I'm talking about HLS, if that matters.

Thanks !

@eshkoliGilad
Copy link

Actually, when using a multiplier bigger than 2 it make the video freeze, any idea why ?

@ojw28
Copy link
Contributor

ojw28 commented Jun 29, 2016

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.

@eshkoliGilad
Copy link

eshkoliGilad commented Jun 29, 2016

@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.
The issue is that it keep seeking ahead of video time (I use a custom seekbar) until really ends the video playback and the video freezes.

Is there any solution to this ?

@ojw28
Copy link
Contributor

ojw28 commented Jun 29, 2016

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.

@yangwuan55
Copy link

@eshkoliGilad Are you sure the [https://gist.github.com/jmgirven/4e0ba2c7d584c8695549](First effort) can work?
I use the VariableSpeedMediaCodecAudioTrackRenderer to replace the MediaCodecVideoTrackRenderer,but it can't work,or it's my wrong?Hope to get your help.
Thanks!

@yangwuan55
Copy link

@ALL Please see here ,I have a implementation of variable speed for exoplayer,support the preversion of 23.

@google google locked and limited conversation to collaborators Jun 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants