C.W.K.
Stream
Lesson 08 of 10 · published

Speed Change

~10 min · speed, setpts, atempo

Level 0Viewer
0 XP0/73 lessons0/15 achievements
0/100 XP to next level100 XP to go0% complete

Speed ≠ frame rate

Changing playback speed is different from changing frame rate. fps drops or duplicates frames; speed change actually re-times the video. The pieces:

  • setpts=PTS*N — multiply video frame timestamps by N. N=0.5 = 2x speed (half the time per frame). N=2 = half speed.
  • atempo=N — change audio tempo without changing pitch. Range 0.5–2.0 per filter — chain for bigger changes.

Common speed values

  • 2x: setpts=PTS*0.5 + atempo=2
  • Half: setpts=PTS*2 + atempo=0.5
  • 3x: setpts=PTS*0.333 + atempo=2,atempo=1.5 (chain)

Code

Speed up / slow down with audio sync·bash
# 2x speed
ffmpeg -i in.mp4 \
  -filter_complex "[0:v]setpts=PTS*0.5[v];[0:a]atempo=2[a]" \
  -map "[v]" -map "[a]" \
  -c:v libx264 -crf 20 -c:a aac -b:a 192k \
  out_2x.mp4

# 0.5x slow motion (without interpolation, frame duplication)
ffmpeg -i in.mp4 \
  -filter_complex "[0:v]setpts=PTS*2[v];[0:a]atempo=0.5[a]" \
  -map "[v]" -map "[a]" \
  -c:v libx264 -crf 20 -c:a aac -b:a 192k \
  out_slow.mp4
Smooth slow-mo with motion interpolation·bash
# Real 30→120 motion-interpolated slow-mo (4x slower with synthesized frames)
ffmpeg -i in.mp4 \
  -filter_complex "[0:v]minterpolate=fps=120:mi_mode=mci:mc_mode=aobmc:vsbmf=1:scd=fdiff,setpts=PTS*4[v]; \
                   [0:a]atempo=0.5,atempo=0.5[a]" \
  -map "[v]" -map "[a]" \
  -c:v libx264 -crf 20 -preset slow \
  -c:a aac -b:a 192k \
  smooth_slowmo.mp4

External links

Exercise

Take a 60-second clip. Speed up to 2x with audio kept in sync. Then slow down to 0.5x without motion interpolation. Then slow down with minterpolate at 120fps and observe the difference (smoother but possibly ghosty). Pick which one you'd ship for: (a) a fast-forward montage, (b) sport replay slow-mo.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.