How to Speed Up or Slow Down Video Playback using FFmpeg

5 October 2022 | 3 min read
Casper Kloppenburg

Prerequisites

FFmpeg is a free and open-source video editing tool capable of trimming, cropping, concatenating, muxing, and transcoding almost any type of media file you throw at it.

It's also a very robust solution for implementing video automation, as we use it extensively in our own video editing API. For this tutorial we'll use FFmpeg 5.1.2, but any recent version will do.

Speeding up a video

Keeping the same frame rate

The following command will speed up a video file by two times, keeping the frame rate the same. In other words, if your input video is 30 frames per second, your output video will also be 30 frames per second, but with half the frames dropped.

$ ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" output.mp4

The -vf "setpts=0.5*PTS" argument sets the PTS (the presentation timestamp) half its original value, effectively doubling the video speed. To speed up the video by four times, use -vf "setpts=0.25*PTS".

Preventing frames from being dropped

There's also a way to speed up the video without losing frames. If you want to do this, you'll have to specify the frame rate you want to end up with. For example, you can double the speed of a 30-fps video to 60 fps by doing the following:

$ ffmpeg -i input.mp4 -r 60 -vf "setpts=0.5*PTS" output.mp4

The addition of the -r 60 argument instructs FFmpeg to force the output file to 60 fps, rather than using the frame rate of the input file.

Slowing down a video

Keeping the same frame rate

You can slow down a video by setting a PTS value higher than 1. For example, here's how you slow down a video by 2 times:

$ ffmpeg -i input.mp4 -vf "setpts=2*PTS" output.mp4

Increasing the frame rate

Video with a low frame rate may become choppy if it is slowed down, as its frame rate may drop below the minimum recommended 25 frames per second. While there is no perfect solution, FFmpeg comes with a filter that can increase the frame rate by motion interpolation. Use the following command to enable this filter, which may take some time as it is CPU intensive:

$ ffmpeg -i input.mp4 -vf "setpts=2*PTS,minterpolate='mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps=60'" output.mp4

Here, the setpts=2*PTS filter instructs FFmpeg to slow down the video by two times, which is combined with the minterpolate='mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps=60' filter to ensure a smooth frame rate of 60. There are several options available to you with the minterpolate filter, which are explained on this page.

Start automating today

Start with a full-featured trial with 50 credits, no credit card required.
Get started for free