25

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.

| improve this question | | | | |
  • 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 Oct 23 '17 at 18:42
  • 7
    @masgo Just FYI, this is now the second highest google search result... – jrh Nov 20 '18 at 18:04
35

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.

| improve this answer | | | | |
  • 2
    While 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 Nov 19 '18 at 21:55
  • 1
    Does it have audio? – Gyan Nov 20 '18 at 5:45
  • 3
    It 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 Nov 20 '18 at 18:12
  • 2
    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 Feb 25 at 4:15
  • 1
    There's a large difference in these two methods in terms of file size, at least for my specific movie. The former outputs a video that's ~100x smaller, while the latter outputs a file that's the same size as the original. – Jessime Kirk Mar 29 at 0:20
5

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
| improve this answer | | | | |
0

I wanted to speed up the audio AND video many times beyond 2x too. For 60x speed, do the following. It may be a bit verbose, but it works great. The problem is that atempo cannot be greater than two or less than 0.5, so we must repeat atempo many times to get the sound to the rate that we want it.

ffmpeg -i input.mkv -filter:v "setpts=PTS/60" -filter:a "atempo=2,atempo=2,atempo=2,atempo=2,atempo=2,atempto=1.875" output.mkv

Press Ctrl+Shift+I to open the console and run the following JS code to generate other speeds. The code also works with slowing down the video. To slow down a video X times, replace 60 with 1/X.

var speed= 60 ; // change 60 to whatever speed you want

var k=speed, audio="";
while (2 < k) k /= 2, audio+="atempo=2,";
while (k < 0.5) k *= 2, audio+="atempo=0.5,";
audio += "atempo=" + k;
console.log(
    'ffmpeg -i input.mkv -filter:v "setpts=PTS/' + speed +
    '" -filter:a "' + audio + '" output.mkv'
);

I hope this helps.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.