How do I speed up a video by 60X in ffmpeg?

19

10

I found this example

 ffmpeg -i input.mkv -filter:v "setpts=0.5*PTS" output.mkv 

but I have a video I want to speed up by 60 times, not just 2X.

watercollider

Posted 2017-10-23T17:25:48.637

Reputation: 193

have you tried Google? Just look at this command and find out what each parameter does. Once you know which one causes the 2x speed it is quite simple to obtain 60x speed. – masgo – 2017-10-23T18:42:17.297

5@masgo Just FYI, this is now the second highest google search result... – jrh – 2018-11-20T18:04:35.993

Answers

28

Simply multiply by the reciprocal of the speed factor.

ffmpeg -i input.mkv -filter:v "setpts=PTS/60" output.mkv

A faster method, but which can have unexpected results with audio (pauses or async):

ffmpeg -itsscale 0.01666 -i input.mkv -c copy output.mkv

where 0.01666 is 1/60 in decimal representation.

Gyan

Posted 2017-10-23T17:25:48.637

Reputation: 21 016

1While the playback speed seems to be changed for this, the video duration seems to be represented incorrectly; e.g., a 3 minute video sped up 3x will still show as being 3 minutes long. If you play it in a video player (e.g., VLC) the video will only take up the first minute and then freeze on a frame for the remaining 2 minutes. – jrh – 2018-11-19T21:55:57.290

1Does it have audio? – Gyan – 2018-11-20T05:45:41.580

2It does make sense that ffmpeg would leave the full length of the video because there was still audio data. Good catch, it turns out, it did have audio (my speakers were muted). With the -an parameter, the length of the video is set properly. – jrh – 2018-11-20T18:12:13.180

this is too slow. for me it's encoding 2 frames/second. i've got about 30 minutes of video! – Michael – 2020-01-19T00:31:12.473

See new method. – Gyan – 2020-01-19T05:08:26.787

The second method is creating a file around 99.99% the size of the input with 60% of the duration - when I play it, I see each individual frame rendered for several seconds. Both with and without -an (although I'm not sure exactly where it's supposed to go) – Michael – 2020-02-25T01:54:17.897

Ok, so correct me if I'm wrong, but the second method is faster because it doesn't actually do anything - the whole video is still there, just with metadata that is instructing the player to play it at an impossibly fast rate. (Which quite honestly, is useless and not what i was expecting) – Michael – 2020-02-25T02:36:27.773

Yes, video playback speed is governed by packet metadata. 60x is a very high speed up and players will usually choke. You'll see more expected results with, say, a 6x speed up. Players can't "skip" frames in a compressed video bitstream since almost all frames depend on one or more surrounding frames for decoding. So, you have to drop frames and re-encode i.e. a timelapse, e.g. ffmpeg -i input -vf framestep=60,setpts=N/30/TB -r 30 -an out.mp4 – Gyan – 2020-02-25T04:15:48.173

1

Note:

If you also want to speed up the audio, you need to do this:

ffmpeg -i input.mkv -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2[a]" -map "[v]" -map "[a]" output.mkv

dopexxx

Posted 2017-10-23T17:25:48.637

Reputation: 111