video-transcoder icon indicating copy to clipboard operation
video-transcoder copied to clipboard

Allow changing of playback speed

Open kingannoy opened this issue 6 years ago • 2 comments

My phone can record video at 60 frames per second, this used to be called the "slow-mo mode". Now my default phone app no longer allows me to save the video with a lower playback speed. So I'm looking for another app that allows me to do this.

I tried saving the vifeo with a different fps but the speed of the video remained the same.

kingannoy avatar Apr 07 '19 16:04 kingannoy

The FPS setting would only reduce the number of frames which were played per second, and if there were more frames present in the original video they would be discarded; it would not affect how quickly the video was played.

I suspect that ffmpeg supports speedup playback. If someone where interested in taking a look into this and proposing some changes I'd be happy to review them.

brarcher avatar Apr 07 '19 17:04 brarcher

Are you looking for this information? https://stackoverflow.com/a/39144362

Or do you need someone to do a pull request? I'm no programmer so I'm afraid that is not possible for me.

If I understand the SO answer correctly, it is possible to change the playback speed while maintaining all frames.

To make playback speed x-times faster (make it slower by setting it smaller then 1) use:

SPEED = user_input
NEW_FPS = CURRENT_FPS / SPEED
NEW_PTS = CURRENT_PTS * SPEED
ffmpeg -i input.mkv -r NEW_FPS -filter:v "setpts=NEW_PTS" output.mkv

This is obviously pseudo code, and probably need a lot more work. The point is that you need to use setpts to change the playback timestamp for all frames while changing the FPS (amount of frames played per second) so that this matches the new reality.

For users that want to speed up the video there should probably be a sensible default max FPS to prevent a video that is set to 8x playbackspeed to end up with 200 FPS.

kingannoy avatar Apr 11 '19 06:04 kingannoy