Avisynth Stab
Stab removes small, fast camera shake, for example the jitter of bad film transfers. Hybrid uses the script Stab3s, a variant of the Stab script family.
Filtering → Avisynth → Frame → Stabilize

What it does
For every frame the shift (and optionally the zoom) against a smoothed reference of neighbouring frames is measured with DePan, and the frame is moved back. Uncovered edges can stay black, be mirrored or, by default, be filled from the unstabilized source and inpainted. Stab corrects translation and zoom, not rotation. It needs progressive input.
Requirements
CPU only. Needs DePan, DePanEstimate and FFTW. Luma expansion = AutoAdjust needs the AutoAdjust plugin; Fill borders needs AvsInPaint, RT_Stats, neo-fft3d, MaskTools2, GRunT and ImageSeq. Hybrid ships them.
Settings
| Control | Parameter | Range | Hybrid default | Meaning |
|---|---|---|---|---|
| Stab | – | on/off | off | Enables the filter. |
| Shift (max X/Y) | dxmax / dymax | 0–32768 each | 0 / 0 | Largest shift that is corrected. 0 = automatic (width / 180 horizontally, vertically the same). Values are capped to the frame size. |
| Mirror | mirror | no mirror, top, bottom, left, right, all | no mirror | Fills uncovered edges by mirroring the picture. Disabled while Fill borders is on. |
| Soften radius | ts | 1–7 | 7 | Number of frames before and after that are averaged into the reference. |
| Max. zoom | zoom | 1–10 (step 0.01) | 1 | Largest zoom that is estimated; 1 = no zoom correction. |
| PAR (W:H) | PAR | 0–999999 each | 0:0 | Pixel aspect ratio, which matters for zoom and non-square pixels. 0 in either field: Hybrid passes the pixel aspect ratio of the output. |
| Luma expansion | Luma_Exp | off, TV to PC levels, AutoAdjust | TV to PC levels | Stretches the contrast of the clip used for motion estimation only; the output is not changed. |
| Fix false positives | FixFalPos | on/off | on | Frames whose result shows a black edge wider than 2 pixels (3 with Fill borders) are replaced by the unstabilized frame. |
| Fill borders | FillBorder / useDePanAlpha | on/off | on | Fills uncovered areas from the source and inpaints them. Several times slower. Off: borders are left as they are, or mirrored. |
| Range | range | 1–1000 | 1 | Number of frames before and after used for motion estimation. Larger is steadier but follows real pans more slowly. |
| Force greyscale | – | on/off | off | Appends .Greyscale() to avoid random color casts.
|
Example
Default settings on a 10-bit YUV 4:2:0 source. Hybrid converts to 8 bit and back:
# stabilizing using Stab3s # Converting from 10 to 8bit for Stab ConvertBits(8) Stab3s() # Converting from 8 to 10bit for encoder ConvertBits(10)
How Hybrid calls it
- Hybrid loads DePanEstimate.dll, DePan.dll, FFTW and Stab3.avsi, plus the extra plugins listed under Requirements when needed.
- The filter needs 8-bit YV12 and progressive input; Hybrid adds the conversions.
- Only values that differ from the script's defaults are written. With Fill borders off, Hybrid writes
FillBorder=0, useDePanAlpha=0. - Stab also offers the common options and can be added to the filter queue several times.
Background
Stab3.avsi describes itself as Dogway's Stab2 with some changes. The line goes from Stab by g-force (the stand-alone version is by McCauley) through Dogway's Stab2 to this variant from realfinder's AVS-Stuff. The motion estimation is DePan by Fizick. Small jitter wants low shift limits; the DePan defaults aim at large shake. Hybrid does not offer a custom luma-estimation clip.
See also: Vapoursynth Stab
Sources
- Doom9: stabilization discussion
- realfinder/AVS-Stuff
- Dogway's AviSynth scripts
- Hybrid's tooltips
- The AviSynth+ documentation does not cover Stab.