Skip to main content

Crate ffcine_stabilize

Crate ffcine_stabilize 

Source
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.

  1. detect (feature nvof): NVDEC decode, scale_cuda to 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).
  2. 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.
  3. hook::warp_hook: the warps as an mpv .hook for 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/1 effect: its parameters as StabilizeParams.
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 Motions detect produces, so smoothing, zoom and warp don’t change.
hook
The per-frame warps as an mpv .hook user 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§

DetectParams
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 (sigma frames) version.
MotionDetection
What detect_motion found, and how.
MotionOptions
Which motion source to use, and how.
SourceRange
The frames to analyse, indexed like render.py’s shots: -ss start on the input, then setpts=PTS-STARTPTS,fps=rate, frames frames (the last repeats if the source runs out).
Stabilization
StabilizeParams
Smoothing and zoom; the defaults are render.py’s (smoothing 20, optzoom 1).

Enums§

FlowQuality
Optical flow engine speed/quality trade-off (NVOF perf level).
MotionSource
Where a stabilizer’s camera motion comes from.

Functions§

fold_crop
Folds a static source crop (x, y, width, height) (source pixels) into transforms, for a pass that renders the full width x height frame: output pixel d of 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 the MAIN hook the crop, so the grade pass crops this way instead.
jitter
Jitter of motions (as from detect), skipping the frame pairs ending at the indices in exclude (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).