Speed up video to 2x with setpts and atempo (faster motion, audio preserved)
Time-lapse style: 2x fast motion compresses a long recording into half its duration. The setpts filter speeds up the video by halving the presentation timestamps; the atempo filter speeds up the audio without changing its pitch. The result plays at double speed.
The command
ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" -filter:a "atempo=2.0" output.mp4What it does
0.5*PTS halves every presentation timestamp, so a frame that was at 1s is now at 0.5s, the frame at 2s is at 1s, and so on. The output is half the duration. atempo=2.0 doubles audio speed using a phase-vocoder algorithm that preserves pitch (a person speaking at double speed still sounds normal, just faster).
When to use it
For time-lapse, long boring sequences, sports highlights, or any time you want to compress time. The audio is sped up without pitch shift, which is the right behavior for most content; for music, atempo=2.0 does speed it up audibly, and you may want to drop the audio or replace it.
Video and audio requirements
Any decodable source. atempo accepts values from 0.5 to 2.0; for greater speedup, chain multiple atempo filters (atempo=2.0,atempo=2.0,atempo=2.0 for 8x). For 0.5x to 2.0, a single atempo works.
Things to avoid
- Going beyond 2x with a single
atempo. It will warn or fail; chain multipleatempofilters for greater speed. - Using
setptswith a constant that does not preserve the original time base.setpts=N*PTSwhere N is the inverse of the speed: 0.5 for 2x faster, 2.0 for 0.5x slower. A wrong sign or value produces a black or fast-forwarded output. - Expecting the audio to be intelligible at 4x.
atempopreserves pitch but cannot preserve intelligibility at high speed; speech becomes chipmunk-like past 2x. Slow the video or drop the audio. - Forgetting that the filter is per-stream. The video filter applies to the video stream; the audio filter applies to the audio stream. If you forget the audio filter, the output has sped-up video and normal-speed audio, which is jarring.