Speed up or slow down a video

Changes video and audio speed together, which needs two filters because one alone desynchronises the file.

ffmpeg -i https://cdn.rendobar.com/assets/examples/sample.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" -t 5 out.mp4
Encode
681 ms
Output
413.6 KB
Cost
$0.0022
Result
1280x720

job_d3a1fc6095a549e3

The part everyone gets wrong

The two factors are inverses of each other. Doubling speed is setpts=0.5*PTS for video and atempo=2.0 for audio. Getting them the same way round is the classic bug. atempo also caps at 2.0 per instance, so 4x needs atempo=2.0,atempo=2.0.

What the common version does

setpts speeds up the video only, and copying the audio leaves it at the original speed, so the two drift apart immediately.

ffmpeg -i https://cdn.rendobar.com/assets/examples/sample.mp4 -vf setpts=0.5*PTS -c:a copy -t 5 out.mp4
It succeeds, and that is the problem

It did not error. It produced 433.3 KB against the correct command's 413.6 KB, a 1.0x larger file. A pipeline would accept this silently.

job_df145596e5764e36

Frequently asked questions

How do I speed up video ffmpeg?

Changes video and audio speed together, which needs two filters because one alone desynchronises the file.

What goes wrong most often?

The two factors are inverses of each other. Doubling speed is setpts=0.5*PTS for video and atempo=2.0 for audio. Getting them the same way round is the classic bug. atempo also caps at 2.0 per instance, so 4x needs atempo=2.0,atempo=2.0.

What happens if I get it wrong?

We ran the naive version too. It did not error. It produced 433.3 KB against the correct command's 413.6 KB, a 1.0x larger file. A pipeline would accept this silently.

Do I need FFmpeg installed?

Not with Rendobar. The command on this page ran through the API against a URL, with no local FFmpeg and no server. The job id below it is the job that produced these numbers.

Run this without installing FFmpeg

This exact command ran through the API against a URL.