Originally published at ffmpeg-micro.com .
You need to speed up a video for a timelapse effect or slow it down for dramatic slow motion. FFmpeg handles both with two filters: setpts for video and atempo for audio. But getting them to work together without desyncing audio or producing choppy output trips up most developers.
This guide covers both the raw FFmpeg CLI commands and how to do the same thing with a simple API call through FFmpeg Micro.
How setpts Controls Video Speed
The setpts (set presentation timestamps) filter controls how fast video frames play back. The formula is simple: multiply the PTS value to slow down, divide to speed up.
Double speed (2x faster):
ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" -an output_fast.mp4
Enter fullscreen mode
Exit fullscreen mode
The 0.5*PTS halves the timestamp gaps between frames, so they display twice as fast.…