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

Solution 1:

Simply multiply by the reciprocal of the speed factor.

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

This does not affect the audio speed. Use -an to not include audio in the output.


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.

Solution 2:

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

Docs: https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video

The command above works if you want to multiply by 2 the speed. If you want to multiply by any x (between 0 and 2), the parameters become:

  ffmpeg -i input.mkv -filter_complex "[0:v]setpts=<1/x>*PTS[v];[0:a]atempo=<x>[a]" -map "[v]" -map "[a]" output.mkv

For instance, if you want to multiply by 1.15, the command is

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

Solution 3:

For a stop-motion project where I wanted to reduce the delay between frames (instead of dropping frames), 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,atempo=1.875" output.mkv

Press Ctrl+Shift+I, and click the "console" tab. In the console, to start typing/pasting text, click in the whitespace just right of the blue horizontal chevron (double chevron in FireFox). In Firefox, type allow pasting into the console to allow copy'n'paste, then Ctrl+A then backspace to remove that text. Then, copy and paste this code into the console and press Enter to run. The code also works with slowing down the video.

var speed=eval(prompt("Enter speed up or slowdown factor (>1 is speedup, " +
    "<1 is slowdown; can use 1/X for slowdown): ", "60"));

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

This code will prompt you to enter a value and present you with the result. Entering 60 yields a 60X speedup, entering 0.1 yields a 10X slowdown, and entering 1/30 yields a 30X slowdown. I hope this helps.

Solution 4:

For me, using setpts in conjunction with atempo left the audio rate low (and with low pitch). What finally worked for me is:

#!/bin/sh
# Note: First use ffprobe to get the audio rate.
# Adjust below if it's not 48000.
# The example below increases the speed of audio and video
# rate by a factor of 4 (adjust as needed).
# Sources:
# https://superuser.com/questions/1261678/how-do-i-speed-up-a-video-by-60x-in-ffmpeg
# https://stackoverflow.com/questions/53374590/ffmpeg-change-tone-frequency-pitch-audio
ffmpeg -i $1 -filter:v "setpts=PTS/4" -af "asetrate=48000*4,aresample=48000" out.mp4