The best results come from vidstab, which works in two passes. The first pass (vidstabdetect) analyzes camera motion across the whole clip and writes it to a transforms file. The second pass (vidstabtransform) uses that data to counter-move each frame. Two passes means it can plan smoothing using future frames, not just past ones.
Key takeaways
- Pass 1:
vidstabdetectmeasures motion into a.trffile. - Pass 2:
vidstabtransformapplies the correction. - Higher
smoothing= steadier but more cropping at the edges. deshakeis a single-pass fallback when vidstab isn't available.
Two-pass stabilization (vidstab)
Run detection first, then the transform. vidstab requires an FFmpeg build compiled with --enable-libvidstab:
# pass 1: analyze motion -> transforms.trf ffmpeg -i in.mp4 -vf vidstabdetect=shakiness=5:accuracy=15 -f null - # pass 2: apply the correction ffmpeg -i in.mp4 -vf \ "vidstabtransform=smoothing=30:input=transforms.trf,unsharp=5:5:0.8" \ -c:a copy out.mp4
Tune smoothing and hide the edges
Stabilization shifts frames, exposing empty borders. Raise smoothing for steadier motion and let vidstabtransform zoom in slightly to crop the edges out:
ffmpeg -i in.mp4 -vf \ "vidstabtransform=smoothing=50:zoom=5:optzoom=0:input=transforms.trf" \ -c:a copy steady.mp4
Quick single-pass deshake
If your build lacks vidstab or you just need a fast pass, the built-in deshake filter works in one go — less smooth, but no setup:
ffmpeg -i in.mp4 -vf "deshake" -c:a copy out.mp4
Stabilize visually instead
FFmpegLab runs both stabilization passes for you behind a single toggle and previews the smoothed result before you commit — all offline, so raw footage never leaves your device. After stabilizing, crop any leftover edges or compress for delivery.