Stabilize Shaky Video with FFmpeg (vidstab)
Two-pass command to analyze camera shake and smooth it out of your footage.
Run vidstabdetect first to write transforms.trf, then vidstabtransform to render the smoothed video.
01Command
Command
$ ffmpeg -i shaky.mp4 -vf vidstabdetect=shakiness=5:accuracy=15 -f null -
ffmpeg -i shaky.mp4 -vf vidstabtransform=smoothing=20:input="transforms.trf" -c:a copy stable.mp402What it does
Stabilization works in two passes: vidstabdetect analyzes motion frame by frame and saves it to transforms.trf, then vidstabtransform applies a smoothed counter-motion to produce the stable video. Higher shakiness (1–10) catches stronger shake; smoothing controls how aggressively motion is damped. Audio is copied untouched with -c:a copy.
03Risk
!Warning: Heavy stabilization crops in and can produce wobbly edges — lower smoothing or increase optzoom settings if the result looks distorted.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- vidstabdetect — FFmpeg Filters DocumentationEvidence: Documents the vidstabdetect pass (shakiness, accuracy) and the companion vidstabtransform pass (smoothing, input trf file).
Last verified: 2026-09-18 · Category: Media