How to Use FFmpeg setpts for Slow Motion

This article explains how to use the setpts video filter in FFmpeg to create a high-quality slow-motion effect. You will learn the basic command-line syntax, how the presentation timestamp (PTS) math works to slow down video footage, and how to adjust the accompanying audio track so it remains perfectly in sync with your slowed-down video.

Understanding the setpts Filter

The setpts filter works by modifying the Presentation Timestamp (PTS) of each video frame. The PTS decides exactly when a specific frame is displayed during playback.

To create a slow-motion effect, you must increase the time interval between frames. You do this by multiplying the PTS by a scaling factor greater than 1.0. For example: * Multiplying by 2.0 makes the video run at 0.5x speed (half speed). * Multiplying by 4.0 makes the video run at 0.25x speed (quarter speed).

Basic Slow Motion Command (Video Only)

If you only want to slow down the video track and do not need the audio, use the following command. This example slows the video down to half speed (0.5x):

ffmpeg -i input.mp4 -filter:v "setpts=2.0*PTS" -an output.mp4

Slowing Down Video and Audio Together

When you slow down a video, the audio does not automatically slow down with it. To slow down both elements and keep them synchronized, you must use the atempo audio filter alongside setpts.

Because atempo accepts a speed factor (where 0.5 is half speed), its value is the inverse of the multiplier used in setpts.

Here is the command to slow both video and audio to half speed (0.5x):

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

Note: The atempo filter only supports values between 0.5 and 2.0. If you want to slow your video down even further (e.g., to 0.25x speed), you must chain multiple atempo filters together, like this: atempo=0.5,atempo=0.5.