Expand description
Video stabilization: optical-flow motion detect on the GPU, camera path smoothing on the CPU,
and a per-frame warp (Mat3, output pixel -> source pixel) for the grade pass.
detect(featurenvof): NVDEC decode,scale_cudato an analysis size, NVIDIA optical flow between consecutive frames, a robust similarity per frame (motion::estimate). Cached on disk by source and parameters (detect_cached).stabilize: the camera path, vidstab’s Gaussian smoothing, and the static zoom that keeps every frame free of black borders. Cheap, so it is recomputed every time.hook::warp_hook: the warps as an mpv.hookfor libplacebo.
gyro is the other way to get the motions of step 1, from what the camera recorded;
detect_motion chooses between them.
Re-exports§
pub use cache::motions_text;pub use gyro::GyroParams;pub use motion::EstimateParams;pub use motion::Motion;pub use path::Zoom;
Modules§
- cache
- On-disk cache of detect results, keyed by the source file (canonical path, size, mtime), the
range, and the motion source with its parameters. Plain text in
$XDG_CACHE_HOME/ffcine/stabilize/. - fx
- The timeline’s
ffcine.fx.stabilize/1effect: its parameters asStabilizeParams. - gyro
- Camera motion from recorded attitude or gyro readings instead of optical flow: per-frame
rotation between frames, projected through a focal length to the same
Motionsdetectproduces, so smoothing, zoom and warp don’t change. - hook
- The per-frame warps as an mpv
.hookuser shader for libplacebo. - motion
- Global motion between two frames from a block flow field: a robust similarity fit (RANSAC on two-point samples, then iteratively reweighted least squares).
- path
- Camera path smoothing (vidstab’s Gaussian
cameraPathGaussian) and the static zoom that keeps every corrected frame inside the source.
Structs§
- Detect
Params - Detection
- What detect found: per output frame, the motion from it to the previous frame in source
pixels (
motions[0]is the identity). - Jitter
- High-frequency residual motion of a clip, the stabilization quality metric: RMS of the
frame-to-frame motion minus its Gaussian-smoothed (
sigmaframes) version. - Motion
Detection - What
detect_motionfound, and how. - Motion
Options - Which motion source to use, and how.
- Source
Range - The frames to analyse, indexed like render.py’s shots:
-ss starton the input, thensetpts=PTS-STARTPTS,fps=rate,framesframes (the last repeats if the source runs out). - Stabilization
- Stabilize
Params - Smoothing and zoom; the defaults are render.py’s (
smoothing20, optzoom 1).
Enums§
- Flow
Quality - Optical flow engine speed/quality trade-off (NVOF perf level).
- Motion
Source - Where a stabilizer’s camera motion comes from.
Functions§
- fold_
crop - Folds a static source crop
(x, y, width, height)(source pixels) intotransforms, for a pass that renders the fullwidth x heightframe: output pixeldof the full-size intermediate maps to crop position(x + d.x * cw / w, y + d.y * ch / h), then through the warp. libplacebo only shows theMAINhook the crop, so the grade pass crops this way instead. - jitter
Jitterofmotions(as fromdetect), skipping the frame pairs ending at the indices inexclude(cuts, punch-ins) in both the smoothing and the RMS.- stabilize
- Smooths the detected camera path and computes the per-frame warps.
- transforms_
text - Warps as text: per frame, the row-major 3x3 matrix (output pixel -> source pixel).