> ## Content Index
> Fetch the complete content index at: https://ffmpeguru.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Stabilize shaky video with vidstab
- URL: https://ffmpeguru.com/stabilize-shaky-video-with-vidstab/
- Published: 2026-08-18T09:00:00.000Z
- Updated: 2026-10-13T17:59:38.000Z
- Author: FFmpeguru
- Tags: ffmpeg

Handheld phone footage, action-cam clips, and drone passes without a gimbal are rarely stable. The vidstab filter set detects the camera motion in a first pass, then applies a smoothing transform in the encode pass. The result looks like the camera was on a tripod, with a small zoom-in to cover the edge motion.

## The command

```
ffmpeg -i shaky.mp4 -vf vidstabdetect=shakiness=5:accuracy=15 -f null -
ffmpeg -i shaky.mp4 -vf vidstabtransform=smoothing=30 -c:v libx264 -crf 20 out.mp4
```

## What it does

The first command analyzes the video and writes a \`transforms.trf\` file with the per-frame motion vector. The second command applies the inverse transform to smooth the motion. The \`shakiness\` value (1-10) controls how aggressive the detection is; \`smoothing\` (1-100+) controls how much of the detected motion is removed. Higher smoothing gives a more tripod-like result, at the cost of more zoom-in.

## Requirements

A two-pass workflow. vidstab is in libavfilter and works on the CPU. No special hardware, no special build flag, but the analysis pass adds a one-time cost equal to a real decode.

## Things to avoid

- Skipping the analysis pass and applying vidstabtransform directly. The transform filter needs the \`.trf\` file the analysis pass produces.
- Setting smoothing very high on a clip that has intentional motion. Smooth-then-stabilize will fight pans and reveal them as tiny stutter.
- Forgetting the zoom cost. The transform slightly enlarges the frame so the smoothed edges fit. Compensate by scaling the output down a few percent, or by cropping to a slightly smaller target resolution.
- Running vidstab on already-stable footage. It cannot fix optical flow problems (rolling shutter, fast pans) — it only fixes translational and rotational shake.