---
title: "Stabilize Video with FFmpeg (vid.stab) | stabilize.video"
description: "How to stabilize a video with FFmpeg: the two-pass vidstabdetect and vidstabtransform commands, what each option does, the quick deshake filter and pitfalls."
url: https://stabilize.video/stabilize-video-ffmpeg
---

1. [Home](https://stabilize.video/)
2. [Stabilisation software](https://stabilize.video/video-stabilization-software)
3. FFmpeg

Guide · free tool included

# Stabilize video with FFmpeg

The two commands that steady a clip with FFmpeg’s vid.stab filters, the options worth changing, a loop for a whole folder and a one-line fallback when your build lacks them.

FFmpeg stabilises video in two passes with the vid.stab library: `vidstabdetect` measures how the camera moved and writes it to a file, then `vidstabtransform` reads that file and moves each frame to cancel the shake. Both are free, run on your own computer and suit batches of files and servers well.

Prefer not to use a terminal? The tool at the top of this page does the same job in your browser, with a rolling-shutter fix and a before-and-after view that vid.stab doesn’t have; the table further down maps each vid.stab option to its control. For other desktop options, see the [comparison of stabilisation software](https://stabilize.video/video-stabilization-software).

## How to stabilize a video with FFmpeg

1. ### Check your build has vid.stab
Run `ffmpeg -filters` and look for `vidstabdetect` and `vidstabtransform`. Most full builds include them (they are compiled in with `--enable-libvidstab`); some minimal ones don’t.
2. ### Measure the shake
Run the first pass. It writes `transforms.trf` next to your video and makes no video file.
3. ### Apply the correction
Run the second pass with the same input. It encodes the picture again and copies the sound unchanged.
4. ### Adjust and repeat
If the result is still jittery, raise `smoothing`; if it crops too much, lower it or set a negative `zoom`. Only the second pass needs running again.

## The two commands

Pass one measures the motion. `shakiness` (1 to 10, default 5) says how shaky and quick the camera is; `accuracy` (1 to 15, default 15) trades speed for precision.

```
ffmpeg -i input.mp4 -vf vidstabdetect=shakiness=5:accuracy=15:result=transforms.trf -f null -
```

Pass two applies it. `smoothing=30` averages the camera over 61 frames (2 × 30 + 1); `interpol=bicubic` gives a sharper result than the default bilinear; the `unsharp` filter restores a little of the crispness the zoom takes away; `-c:a copy` keeps the sound as it is.

```
ffmpeg -i input.mp4 -vf vidstabtransform=input=transforms.trf:smoothing=30:interpol=bicubic,unsharp=5:5:0.8:3:3:0.4 -c:v libx264 -crf 18 -preset slow -c:a copy output.mp4
```

## Options worth knowing

* `smoothing`: how many frames either side are averaged (default 15). Higher is calmer, but follows deliberate pans less closely.
* `optzoom`: 1 (the default) picks one zoom for the whole clip that hides the edges, 2 changes it as the shake changes (at most `zoomspeed` per cent per frame), 0 turns it off.
* `zoom`: extra zoom in per cent; a negative value zooms out and shows more of the frame.
* `crop=black`: fill the uncovered edges with black instead of keeping the previous frame’s edge (`keep`, the default).
* `tripod=1` on both passes: hold the camera completely still, as if on a tripod, relative to the first frame.
* `optalgo`: `opt` (the default) optimises the whole path; `gauss` and `avg` are simpler moving averages.
* `show=1` on the first pass, written to a video instead of `-f null`, draws the measured motion so you can check it.

## Stabilising a folder of clips

In a Mac or Linux terminal (or Git Bash on Windows), this loop steadies every MP4 in the current folder and saves each as `stable-` plus its name. It reuses one `transforms.trf`, since each clip is measured and corrected before the next one starts.

```
for f in *.mp4; do
  ffmpeg -i "$f" -vf vidstabdetect=result=transforms.trf -f null -
  ffmpeg -i "$f" -vf vidstabtransform=input=transforms.trf:smoothing=30:interpol=bicubic -c:v libx264 -crf 18 -c:a copy "stable-$f"
done
```

## From vid.stab options to the studio’s controls

The stabiliser on this page works on the same ideas, with named controls instead of options, and re-plans the camera path the moment you change one, so there’s no second pass to wait for.

__vid.stab options and their equivalents here__
| vid.stab                  | What it does                 | Here                                                  |
| ------------------------- | ---------------------------- | ----------------------------------------------------- |
| smoothing                 | How calm the camera becomes  | **Smoothness**                                        |
| tripod=1                  | Holds the frame still        | **Camera**: **Locked** (the **Tripod** preset)        |
| optzoom=1                 | One zoom for the whole clip  | **Framing**: **Crop to fit**                          |
| optzoom=2                 | Zoom that follows the shake  | **Framing**: **Smart zoom**                           |
| optzoom=0 with crop=black | No zoom, black edges         | **Framing**: **Full frame** with **Edges**: **Black** |
| zoom                      | Extra zoom in per cent       | **Extra zoom**                                        |
| (none)                    | Rolling-shutter correction   | **Rolling shutter**: **Auto** or **Manual**           |
| (none)                    | Perspective and local wobble | **Correction**: **Perspective** or **Warp**           |

## How the two compared on our test clips

In November 2026 we ran vid.stab and the stabiliser on this page over the same 11 short clips: six real clips (walking, hiking, a concert, a car interior, skiing and cycling) and five steady clips with shake added, so their true camera path is known. A separate tracker, which shares no code with either, measured the shake left between 1.5 and 15 Hz, the range of hand tremor, footsteps and vibration.

* With its default settings, the stabiliser on this page removed 54% of that shake, against 31% for vid.stab with `smoothing=30`.
* It left less shake than vid.stab on 10 of the 11 clips.
* On the five clips with a known true path, it removed 72% of the shake, against 64% for vid.stab.
* vid.stab kept slightly more of the frame on most clips, because with `crop=keep` it lets the previous frame’s edge show at the worst moments. With its default settings the browser stabiliser never shows an empty edge; it zooms in a little instead.

Eleven clips is a small sample, and your footage may behave differently, so compare both on a clip of your own before you settle on one.

## The one-line fallback: deshake

If your FFmpeg has no vid.stab, the built-in `deshake` filter works in one pass. It corrects only sideways and up-and-down shifts, not rotation, looking for movements of up to 16 pixels by default (`rx` and `ry`, at most 64), so it suits gentle shake best. By default it mirrors the picture into the uncovered edges.

```
ffmpeg -i input.mp4 -vf deshake -c:a copy output.mp4
```

## FFmpeg stabilisation questions

### Why does FFmpeg say “No such filter: vidstabdetect”?

Your build was made without the vid.stab library. Install a full build that includes it, or use the one-pass `deshake` filter instead.

### Why is the stabilised video zoomed in?

By default `optzoom=1` zooms just enough to hide the moving edges. Set `optzoom=0` to turn that off and decide the edges yourself with `crop` and `zoom`.

### Does vid.stab keep the audio?

Only if you ask: add `-c:a copy` to the second pass to copy the sound across unchanged.

### How do I make the camera look locked off, like a tripod?

Add `tripod=1` to both the vidstabdetect and vidstabtransform options. It only works when the shot doesn’t need to pan; [locked-off shots](https://stabilize.video/locked-off-shot) explains the limits.

### Which is better, vidstab or deshake?

vid.stab, in most cases: it measures the motion across the whole frame, including rotation, and plans a smoother path over many frames. deshake is quicker to type and comes with standard FFmpeg builds.

### Can FFmpeg fix rolling shutter or jello?

Not with vid.stab or deshake: both treat each frame as one rigid picture, so the lean and wobble of a rolling shutter stay. The [rolling shutter page](https://stabilize.video/rolling-shutter) explains the effect and fixes it in the browser.

## More on stabilising in other apps

* [ Stabilize a video online Smooth out shaky footage in your browser, with nothing uploaded. ](https://stabilize.video/)
* [ Compare video stabilisation software Free and paid stabilisers side by side, from Resolve and Warp Stabilizer to Gyroflow and FFmpeg. ](https://stabilize.video/video-stabilization-software)
* [ Make handheld footage look locked off Hold the frame completely still, like a tripod shot, instead of just smoothing it. ](https://stabilize.video/locked-off-shot)
* [ Stabilize video without cropping Keep the whole frame and fill the edges, or zoom only where the shake needs it. ](https://stabilize.video/stabilize-video-without-cropping)
* [ Fix a shaky video Which kinds of shake can be removed, which can’t, and the preset for each. ](https://stabilize.video/fix-shaky-video)
