brarcher / video-transcoder

Android app for video and audio transcoder, based on FFmpeg
GNU General Public License v3.0
480 stars 57 forks source link

Allow changing of playback speed #156

Open kingannoy opened 5 years ago

kingannoy commented 5 years ago

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.

brarcher commented 5 years ago

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.

kingannoy commented 5 years ago

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.