Passtape.
Menu

What is Passtape?

Passtape is an MIT-licensed media engine for processing video and audio. It is made to be the foundation of professional nonlinear editors and other media applications.

  • Video processing runs on the GPU and keeps frames GPU-resident between operations.
  • Backends use the native codecs, media surfaces, and GPU APIs of each platform.
  • The library is MIT licensed and can be used in commercial products.

The complete backend today is macOS, using VideoToolbox, Core Video, Metal, and the platform audio frameworks. Windows and Linux backends are being developed around the same platform-neutral graph API.

Example usage

This example opens a video, keeps the section from 2 to 8 seconds, crops its edges, applies a Gaussian blur, and encodes the result as H.264 in a MOV file.

use passtape::{
    H264Mov, MediaGraph, PlaybackRate, RationalTime, RequestedVideoOutput,
    TimeMap, TimeRange, new_runtime,
    ops::{retime, video_blur_gaussian, video_transform_2d},
};

let mut runtime = new_runtime()?;
let source_info = runtime.sources_mut().add_file("input", input_path)?;

let mut graph = MediaGraph::builder("edit");
let source = graph.add_video_source(
    "input",
    source_info.full_range(),
    source_info.descriptor(),
)?;

// Timeline seconds 0-6 play source seconds 2-8 at normal speed.
let start = RationalTime::from_integer(2);
let edit_range = TimeRange::new(
    RationalTime::ZERO,
    RationalTime::from_integer(6),
)?;
let cut = graph.add_operation(retime::Options {
    id: "cut",
    input: source,
    active_range: edit_range,
    time_map: TimeMap::affine(
        RationalTime::ZERO,
        start,
        PlaybackRate::new(1, 1)?,
    ),
})?;

let zero = graph.add_scalar_parameter("zero", 0.0)?;
let one = graph.add_scalar_parameter("one", 1.0)?;
let center = graph.add_scalar_parameter("center", 0.5)?;
let crop_x = graph.add_scalar_parameter("crop-x", 0.10)?;
let crop_y = graph.add_scalar_parameter("crop-y", 0.05)?;
let cropped = graph.add_operation(video_transform_2d::Options {
    id: "crop",
    active_range: edit_range,
    input: cut,
    translation_x: zero,
    translation_y: zero,
    scale_x: one,
    scale_y: one,
    rotation_degrees: zero,
    anchor_x: center,
    anchor_y: center,
    crop_left: crop_x,
    crop_top: crop_y,
    crop_right: crop_x,
    crop_bottom: crop_y,
})?;

let radius = graph.add_scalar_parameter("blur-radius", 12.0)?;
let blurred = graph.add_operation(video_blur_gaussian::Options {
    id: "blur",
    active_range: edit_range,
    input: cropped,
    radius,
})?;

let output = graph.add_video_output("output", blurred)?;
let requested = RequestedVideoOutput::new(
    output.node_id(),
    H264Mov::new(output_path),
);
let plan = runtime.prepare(
    graph.build(),
    &requested.execution_request(),
)?;

runtime.start_video_output(plan, requested)?.run()?;

Sources, operations, parameters, and outputs are ordinary graph nodes. Replace the constant parameters with keyframe curves to animate the crop, blur, or any other supported control.

Playback

Playback uses the same graph. Instead of an encoder, provide a video output target that presents GPU surfaces in your application, then request frames at the playhead time.

let requested = RequestedVideoOutput::new(
    output.node_id(),
    preview_target,
);
let plan = runtime.prepare(
    graph.build(),
    &requested.execution_request(),
)?;
let mut playback = runtime.start_video_output(plan, requested)?;

playback.render_frame(playhead_time, presentation_time)?;

preview_target is supplied by the application and implements VideoOutputTarget. On macOS it can receive a retained Core Video surface without copying the frame back to the CPU.

Operations

Operations transform media inside a graph. Add one with graph.add_operation(...), connect its input to an earlier node, and pass its output to another operation or graph output. Controls can be constants or keyframed parameters.

let radius = graph.add_scalar_parameter("radius", 12.0)?;
let blurred = graph.add_operation(ops::video_blur_gaussian::Options {
    id: "blur",
    active_range,
    input: video,
    radius,
})?;

The editor drawing operations also include video_motion_blur: eight inverse placement matrices sample one current image over a centered transform shutter. Samples are averaged in premultiplied linear light, then blended over the background. Content itself is not temporally resampled. WebGPU and Metal use the same kernel contract.

video_path accepts optional trim start/end/offset parameters for the stroke. Start/end cover 0–1 of flattened path length and offset wraps; fills stay whole. A path has at most 238 flattened points within the effect uniform budget.

media.data.lens_map generates the source coordinates for a calibrated lens; media.video.stmap_warp applies them to a picture. Both undistortion and redistortion use this shared warp, including imported float STMaps. Keep the original plate outside this chain when redistorting CG for a final composite. Map coordinates use Nuke’s normalized display-window convention with bottom-left UV origin and pixel centres. Colour conversion never applies to map values.

media.video.depth_defocus is an image operation over externally rendered beauty and Z; it does not render geometry or infer scene depth. Focus is a positive camera-axis distance in metres. For normalized axial depth z, the signed circle-of-confusion radius is blur * (1 - focus / z), clipped to the selected maximum; negative radii are near and positive radii are far. blur is the radius at infinity, not a physical f-number. The circular aperture accounts for pixel aspect. Its maximum supported radius is 32 vertical source pixels.

The graph caller must align the two inputs in source time, data/display windows, crop, overscan and pixel aspect before this operation. Do not resample or blur Z to imitate colour filtering at boundaries. Apply lens redistortion after defocus and final raster grain after redistortion. Keep the original plate outside the CG defocus chain. Foxberry validates these relationships when compiling a project; a standalone Passtape graph is responsible for its own source alignment.

The algorithm retains depth ordering while expanding foreground coverage. Its optional bounded fill estimates missing background radiance from available farther samples. It cannot know whether an occluded region contains a surface or empty space, or represent several transparent surfaces with one Z value. The estimated-fill and unfilled-support views show processing weights, not recovered geometry. A true rendered DOF reference can therefore differ at disocclusions even when the input images and settings are correct.

media.data.defocus_counts measures the aligned defocus inputs without rendering Beauty. It takes the same depth interpretation and optical controls and returns a 2×1 RGBA32 Data image. The first pixel stores visible and invalid-depth source-pixel counts; the second stores capped and total counts. Each count is encoded as a low 16-bit component followed by a high 16-bit component: low + 65536 * high. This keeps integers exact above float32’s usual 16,777,216 limit. It measures the source raster including overscan, before placement, masks and lens distortion. Visible means alpha greater than zero; empty alpha needs no valid Z. Capped means a valid visible sample reaches the positive selected radius cap, using the same calculation as the diagnostic view. These counts do not certify colour validity, renderability or hidden geometry. Request this output explicitly; ordinary Beauty and export do not execute the measurement.

Timeline and text

retime

Cuts, offsets, reverses, freezes, or changes the speed of audio or video by mapping output time to input time.

text_render

Renders semantic text as premultiplied-alpha video so it can be transformed and composited like any other visual layer.

Input before text_renderResult of text_render

Audio

audio_mixmedia.audio.mix

Adds two audio streams together over the same timeline range.

Both inputs must have the same sample rate, channel layout, and sample storage. Planar floating-point samples are added without clipping, preserving values outside the range from -1 to 1 for later processing or output conversion.

audio_gain_panmedia.audio.gain_pan

Applies sample-accurate volume and stereo pan controls.

ParameterMeaning
gainLinear amplitude from 0 to 64; 1 is unity gain.
panStereo position from full left (-1) through full right (1).
audio_normalizemedia.audio.normalize

Applies the constant gain calculated by Passtape's whole-program loudness analysis.

ParameterMeaning
gainConstant linear gain resolved by the complete-program loudness analysis.

Supports every prepared planar-f32 speaker layout and preserves relative channel levels. The operation does not perform analysis itself; the gain is resolved by an explicit complete-program loudness analysis before rendering. See Loudness normalization for the two-pass data flow.

audio_eqmedia.audio.eq

Applies one high-pass, low-pass, peaking, low-shelf, or high-shelf filter band. Chain several nodes to build a multiband EQ.

ParameterMeaning
kindFilter kind: 0 high-pass, 1 low-pass, 2 peaking, 3 low-shelf, 4 high-shelf.
frequency_hzFilter cutoff or center frequency, from 10 to 96,000 Hz.
gain_dbSigned boost or cut for peaking and shelf kinds, from -48 to 48 dB.
qResonance or bandwidth as filter Q, from 0.1 to 18.
audio_gatemedia.audio.gate

Reduces audio below a threshold, with attack, hold, release, range, and hysteresis controls.

ParameterMeaning
threshold_dbLevel below which the gate closes, from -120 to 0 dB.
hysteresis_dbExtra level required to reopen a closed gate, from 0 to 48 dB.
attack_ms, hold_ms, release_msTime to open, minimum time held open, and time to close, each from 0 to 10,000 ms.
range_dbAttenuation applied when fully closed, from 0 to 120 dB.
audio_compressormedia.audio.compressor

Reduces dynamic range above a threshold using ratio, knee, attack, release, and makeup gain controls.

ParameterMeaning
threshold_dbLevel where gain reduction begins, from -120 to 0 dB.
ratioSlope above the threshold, from 1 to 100; 1 disables compression.
knee_dbWidth of the soft transition around the threshold, from 0 to 48 dB.
attack_ms, release_msGain-reduction attack and release times, each from 0 to 10,000 ms.
makeup_gain_dbGain applied after compression, from -48 to 48 dB.
audio_limitermedia.audio.limiter

Prevents peaks from exceeding a ceiling while preserving quieter material.

ParameterMeaning
ceiling_dbfsMaximum sample peak, from -60 to 0 dBFS.
release_msTime over which gain recovers after a peak, from 0 to 10,000 ms.

Video composition and geometry

video_depth_defocusmedia.video.depth_defocus

Defocuses an externally rendered linear picture using aligned, unfiltered raw Z. Streams depth layers through a circular aperture, expands foreground coverage and composites far to near.

input frame
after video_depth_defocus
ParameterMeaning
image, depthStraight-alpha linear BT.2020 RGBA16Float picture and matching R32Float Data. Width, height, time, windows and pixel aspect must describe the same render.
focus, blur, max_radiusFocus distance in metres, radius at infinity, and an intentional 0–32 vertical-source-pixel radius cap. These optical controls may be animated.
near, farConstant switches enabling blur closer than and farther than focus.
fill, fill_reachConstant estimated-background-fill switch and donor reach of 0–32 vertical source pixels. Fill cannot recover hidden geometry.
encoding, metres_per_unit0: camera-axis distance; 1: reciprocal axis distance; 2: perspective ray distance. A positive unit scale converts distance to metres (scale/raw for reciprocal depth).
pixel_aspect, fx, fy, cx, cy, origin_x, origin_yFixed pixel aspect in 0.5–2, perspective intrinsics in display-window pixels, and data-window origin relative to that window. Ray depth needs positive focal lengths.
background_enabled, background_thresholdOptional raw finite-background sentinel: distance at/above the threshold, or reciprocal depth at/below it, means infinity. Invalid negative or NaN values remain invalid.
viewConstant transient view: 0 Beauty, 1 signed CoC, 2 invalid visible depth, 3 radius cap, 4 near influence, 5 estimated fill, 6 unfilled support. Ordinary output uses Beauty.

Uses associated float32 intermediates and returns straight-alpha RGBA16Float; HDR and negative RGB are retained within that format. Raw Z is never filtered or colour managed. Positive infinity (and reciprocal zero) is background; invalid visible depth fails active beauty rendering with a source-pixel count. Zero blur, a radius within the pixel-area identity threshold, or both near/far disabled gives an exact Beauty bypass. At most 256 active layers are supported; excess layers fail explicitly. A single Z layer cannot reconstruct disocclusions, transparent overlaps or hidden surfaces. Use separately rendered elements where those distinctions matter. Full-quality output has no real-time guarantee; inspect the chosen radius and raster before committing a long export.

video_blur_gaussianmedia.video.blur.gaussian

Applies a keyframeable Gaussian blur with a radius measured in pixels.

Input before video_blur_gaussianResult of video_blur_gaussian
ParameterMeaning
radiusScalar — how far the blur extends from each pixel, from 0 to 64 pixels.

A radius of 0 preserves the input. Values outside the documented range are rejected during graph analysis. The operation preserves the prepared video format.

video_alpha_overmedia.video.alpha_over

Places premultiplied-alpha foreground video over background video.

Input before video_alpha_overResult of video_alpha_over

A transparent foreground reveals the background; an opaque foreground replaces it. Preparation converts both inputs to the same BGRA color format and a premultiplied-alpha representation — color channels stored already multiplied by alpha, which lets compositing blend correctly with a single multiply-add — before the operation runs.

video_opacitymedia.video.opacity

Changes a video's alpha uniformly from fully transparent to fully opaque.

Input before video_opacityResult of video_opacity
ParameterMeaning
opacityScalar — 0 is fully transparent and 1 leaves the input unchanged.
video_mixmedia.video.mix

Interpolates between two video inputs using a keyframeable mix amount.

Input before video_mixResult of video_mix
ParameterMeaning
amountScalar — 0 selects the first input, 1 selects the second, and values between them blend both inputs.

The inputs are ordered: the first input is selected at an amount of 0, and the second is selected at an amount of 1. Amounts outside the range from 0 to 1 are clamped to the nearest endpoint. Both inputs use the format selected during preparation.

video_transitionmedia.video.transition

Transitions between outgoing and incoming video using dissolve, dip-to-black, or directional wipe modes.

Input before video_transitionResult of video_transition
ParameterMeaning
kindIntegral mode: 0 dissolve, 1 dip-to-black, 2 wipe left-to-right, 3 wipe right-to-left, 4 wipe top-to-bottom, 5 wipe bottom-to-top.
progressReveal progress from 0 (outgoing frame) to 1 (incoming frame), normally keyframed across the range.
video_blendmedia.video.blend

Composites a foreground layer with opacity and normal, add, multiply, or screen blend modes.

Input before video_blendResult of video_blend
ParameterMeaning
opacityForeground opacity from 0 to 1.
modeIntegral blend mode: 0 normal, 1 add, 2 multiply, 3 screen.
video_corner_pinmedia.video.corner_pin

Perspective-maps a frame to four independently keyframeable destination corners.

Input before video_corner_pinResult of video_corner_pin
ParameterMeaning
top_left, top_right, bottom_right, bottom_leftPoint2 — normalized destination corners; coordinates may extend outside [0, 1].

Projectively maps a video frame into four normalized destination points ordered clockwise from top-left. Each corner is a Point2 parameter, so tracking output can animate the perspective mapping without rebuilding the graph. Coordinates may extend outside [0, 1]; pixels outside the mapped source are transparent.

video_fillpasstape.video.fill

Replaces the pixels a hole mask selects with pixels spread in from around it.

input frame
after video_fill
ParameterMeaning
reachHow far from the hole donor pixels may lie, in pixels.
grainStandard deviation of deterministic noise added per frame.
regionsUp to eight mask shapes' boxes and placements, which bound the hole each frame.

Reads the image, the hole, and optionally a surface that donors must lie in and an occluder in front of the hole, each as a frame's alpha. Donors outside every pixel the hole touches are spread by a push-pull pyramid over a box around the hole grown by reach, so the cost follows the hole's size rather than the frame's. An occluder is filled under, then drawn back with a clean colour unmixed at its soft edge.

video_transform_2dmedia.video.transform_2d

Translates, scales, rotates, anchors, and crops video in one operation.

Input before video_transform_2dResult of video_transform_2d
ParameterMeaning
translation_x, translation_yMovement in output pixels.
scale_x, scale_yIndependent scale; negative values flip an axis.
rotation_degreesClockwise rotation in degrees.
anchor_x, anchor_yScale and rotation pivot in normalized source coordinates; 0.5 is center.
crop_left, crop_top, crop_right, crop_bottomNormalized source fraction removed from each edge.

Scale and rotation pivot on the anchor point, then translation moves the result. The operation preserves frame dimensions and makes pixels outside the source transparent. A zero scale produces a transparent frame. Sampling is bilinear; strong minification can alias because the operation does not prefilter or build image pyramids.

Color and HDR

video_color_adjustmedia.video.color_adjust

Adjusts exposure, contrast, saturation, white-balance temperature and tint, vignette, and sharpening.

Input before video_color_adjustResult of video_color_adjust
ParameterMeaning
exposureBrightness from -20 to 20 stops; 1 doubles linear light.
contrastContrast from 0 to 4 around middle gray; 1 leaves it unchanged.
saturationColor intensity from 0 to 4; 0 is grayscale and 1 leaves it unchanged.
temperatureBlue-to-amber white balance from -1 to 1; 0 leaves it unchanged.
tintGreen-to-magenta white balance from -1 to 1; 0 leaves it unchanged.
vignetteEdge-darkening strength from 0 to 1.
sharpenUnsharp-mask strength from 0 to 2.
window_x, window_y, window_width, window_heightConstant display window inside the output, in pixels, that the vignette is measured from; the whole output unless the picture carries an overscan margin.

The adjustment is defined in linear RGB. Preparation converts the input to a supported linear working format and converts the result as needed. The input must declare complete color metadata so saturation has a defined luminance.

video_primary_grademedia.video.color.primary_grade

Applies lift, gamma, gain, offset, contrast, pivot, saturation, temperature, and tint, optionally through a mask.

Input before video_primary_gradeResult of video_primary_grade
ParameterMeaning
lift_r, lift_g, lift_bPer-channel lift, from -4 to 4.
gamma_r, gamma_g, gamma_bPer-channel gamma multiplier, from 0.01 to 10.
gain_r, gain_g, gain_bPer-channel gain, from 0 to 16.
offset_r, offset_g, offset_bPer-channel additive offset, from -4 to 4.
exposureExposure from -20 to 20 stops.
contrastContrast multiplier from 0 to 4.
pivotContrast pivot in normalized linear RGB, from 0 to 1.
saturationSaturation multiplier from 0 to 4.
temperatureBlue-to-amber white balance from -1 to 1.
tintGreen-to-magenta white balance from -1 to 1.
video_color_curvemedia.video.color.curve

Applies a master transfer curve to the image, optionally through a mask.

Input before video_color_curveResult of video_color_curve
ParameterMeaning
strengthCurve blend strength from 0 (bypass) to 1 (full effect).
video_rgb_curvesmedia.video.color.rgb_curves

Applies master and per-channel red, green, and blue transfer curves, optionally through a mask.

Input before video_rgb_curvesResult of video_rgb_curves
ParameterMeaning
strengthCurve blend strength from 0 (bypass) to 1 (full effect).
video_channel_mixermedia.video.color.channel_mixer

Remaps output RGB channels through a keyframeable three-by-three matrix, optionally through a mask.

Input before video_channel_mixerResult of video_channel_mixer
ParameterMeaning
red_from_red … blue_from_blueThe nine row-major matrix coefficients mapping input RGB to output RGB, each from -4 to 4.
red_offset, green_offset, blue_offsetAdditive output-channel offsets, each from -4 to 4.
strengthMixer blend strength from 0 (bypass) to 1 (full effect).
video_hue_curvemedia.video.color.hue_curve

Changes hue, luminance, or saturation as a function of a selected color property, optionally through a mask.

Input before video_hue_curveResult of video_hue_curve
ParameterMeaning
strengthCurve blend strength from 0 (bypass) to 1 (full effect).
video_color_lut_3dmedia.video.color.lut_3d

Applies a three-dimensional RGB lookup table, with optional masked strength.

Input before video_color_lut_3dResult of video_color_lut_3d
ParameterMeaning
strengthLUT blend strength from 0 (bypass) to 1 (full effect).
video_tone_mapmedia.video.tone_map

Maps HDR luminance into a target display range while preserving color and highlight detail.

Input before video_tone_mapResult of video_tone_map
ParameterMeaning
source_peak_nitsDeclared source mastering peak, from 100 to 10,000 nits.
target_peak_nitsTarget display peak, from 48 to 1,000 nits.

Both peaks are constants because they describe the source programme and target display rather than a frame-by-frame effect. Preparation decodes PQ or HLG into linear half-float RGB before this operation and converts the result into the output's requested transfer function afterward. Linear value 1.0 represents 100 nits.

Masks and keying

video_maskmedia.video.mask

Converts the red channel of a video matte into first-class mask data.

Input before video_maskResult of video_mask
video_hsl_qualifiermedia.video.color.hsl_qualifier

Builds complementary inside and outside masks by selecting ranges of hue, saturation, and luminance.

Input before video_hsl_qualifierResult of video_hsl_qualifier
video_chroma_keymedia.video.key.chroma

Keys a selected color and returns complementary foreground and background masks.

Input before video_chroma_keyResult of video_chroma_key
ParameterMeaning
key_colorRGB — key color in linear BT.2020 RGB.
toleranceChroma distance accepted as background coverage, from 0 to 1.
softnessAdditional chroma-distance transition width, from 0 to 1.
video_luma_keymedia.video.key.luma

Builds foreground and background masks from a luminance range.

Input before video_luma_keyResult of video_luma_key
ParameterMeaning
minimum, maximumSelected luminance bounds, each from 0 to 1.
softnessTransition width outside both luminance bounds, from 0 to 1.
video_power_windowmedia.video.color.power_window

Creates a geometric grading mask whose translation, scale, and rotation can be keyframed or driven by tracking data.

Input before video_power_windowResult of video_power_window
ParameterMeaning
translationPoint2 — translation in normalized image coordinates.
scalePoint2 — nonuniform scale relative to the authored window.
rotationClockwise rotation in radians.
mask_levelsmedia.mask.levels

Remaps mask coverage to adjust its black point, white point, and gamma.

Input before mask_levelsResult of mask_levels
ParameterMeaning
black_pointInput coverage mapped to 0, from 0 to 1.
white_pointInput coverage mapped to 1, from 0 to 1.
gammaMidtone exponent from 0.01 to 10; 1 preserves a linear ramp.
mask_mattemedia.mask.matte

Turns a picture's alpha, luminance or HSL key into mask coverage, times its alpha.

input frame
after mask_matte
ParameterMeaning
sourceConstant: 0 alpha, 1 luminance, 2 key.
hue_low … luminance_softnessThe key's nine ranges from 0 to 1, as the HSL qualifier's, but animatable; read only by the key.
mask_morphologymedia.mask.morphology

Expands or contracts a mask spatially.

Input before mask_morphologyResult of mask_morphology
ParameterMeaning
radiusSigned radius in pixels from -64 to 64; positive expands and negative contracts, resolved to the nearest whole pixel.
mask_blurmedia.mask.blur

Softens mask edges with a Gaussian blur.

Input before mask_blurResult of mask_blur
ParameterMeaning
radiusGaussian radius in pixels, from 0 to 64.
video_despillmedia.video.key.despill

Removes color spill aligned with a chroma-key color inside a mask.

Input before video_despillResult of video_despill
ParameterMeaning
key_colorRGB — key color in linear BT.2020 RGB.
amountSuppression amount from 0 (unchanged) to 1 (full neutralization).
video_apply_maskmedia.video.apply_mask

Multiplies a video's alpha by mask coverage.

Input before video_apply_maskResult of video_apply_mask

The mask and the video have the same size. The color is kept and the alpha becomes alpha × coverage, rounded to the nearest half float on every backend, so video_depth_mask gives the same bits as a depth matte followed by this operation.

mask_combinemedia.mask.combine

Combines two masks with pointwise mask algebra.

Input before mask_combineResult of mask_combine
ParameterMeaning
modeIntegral mode: 0 intersect, 1 union, 2 subtract, 3 xor.
mask_previewmedia.mask.preview

Converts a mask into grayscale video for display or debugging.

Input before mask_previewResult of mask_preview

Data images

data_rangemedia.data.range

Measures the finite minimum and maximum of a data image, for a preview whose range follows each frame.

It has no parameters and measures the image's first three channels, or all of them when it has fewer. The output is a 1 × 1 Rg32Float data value: red is the minimum and green the maximum over those channels of every pixel. NaN, +∞, and −∞ are skipped, so a background at infinity does not flatten a preview. A frame with no finite value gives (+∞, −∞), which data_preview treats as an empty range. Between zeros the minimum prefers −0 and the maximum +0, as IEEE 754-2019's minimum and maximum do. Ties are decided explicitly, so the pair does not depend on order and every backend gives the same pair bit for bit, equal to passtape_engine::ops::data_range::measured.

data_previewmedia.data.preview

Shows a data image as an opaque picture for display, without changing its stored values.

ParameterMeaning
modeConstant: 0 grey (first channel), 1 channels (up to three as RGB), 2 IDs.
min, maxFinite values shown as black and white, keyframable; replaced by channels 0 and 1 of pixel (0, 0) of the range input when one is connected, usually a data_range output. The range input needs at least two channels and may have any size.

In grey and channels modes a value x becomes clamp((x·0.5 − min·0.5) / (max·0.5 − min·0.5), 0, 1), which halves every term so that no finite range overflows, and a channel the image lacks shows as 0. +∞ shows as 1, and −∞ and NaN as 0. When max is not above min, or either is infinite, every finite value shows as mid grey (0.5) instead of dividing by zero, so a uniform frame with a measured range is grey. IDs mode reads the first channel's 32-bit pattern, never its value: bits 16–23, 8–15, and 0–7 become red, green, and blue in steps of 1/255, as Cryptomatte's ID view shows them. The output has the data image's size and is opaque Rgba16Float in linear BT.2020, each channel rounded to the nearest half float.

data_depth_mattemedia.data.depth_matte

Makes a mask from a depth image, covering what lies between two depths, for depth holdouts.

ParameterMeaning
near, farFinite depths, keyframable, between which coverage is 1.
softnessFinite and at least 0, keyframable: the width of the linear ramp outside near and far. 0 gives a hard edge.
encodingConstant: 0 depth, where the first channel is distance into the scene as Blender's Z pass stores it; 1 inverse depth, where it is one over the distance, as Nuke's ScanlineRender writes it, so 0 is infinitely far.

The input needs at least one channel; only the first is read. GPUs may flush subnormal numbers, so a subnormal value counts as a zero of its sign. The depth d is the value, or for inverse depth 1 / value correctly rounded: ±0 is ±∞, and a value beyond 2^126, whose inverse would be subnormal, is a depth of ±0. Coverage is 1 when near ≤ d ≤ far. Below near it is clamp((d − near) / softness + 1, 0, 1), and above far clamp((far − d) / softness + 1, 0, 1); each is one fused multiply-add with 1 / softness, which the engine computes once, and the band is tested first so a hard edge never multiplies 0 by ∞. A softness of 0 of either sign, or a subnormal one, is a hard edge; a softness so large that its inverse would be subnormal uses the smallest normal inverse instead; and subnormal near and far values are 0. Coverage is the smaller of the two, so near above far covers only where the ramps overlap. A NaN depth is uncovered, as are infinite depths outside the band. The output is an R16Float mask of the depth image's size, rounded to the nearest half float, which the other mask operations take. Both backends match the engine's reference definition, passtape_engine::ops::data_depth_matte::coverage, exactly.

video_depth_maskmedia.video.depth_mask

Multiplies a picture's alpha by a depth matte's coverage in one pass, for a depth holdout with no edge processing.

ParameterMeaning
near, far, softness, encodingAs for data_depth_matte.

The picture is straight-alpha Rgba16Float, and the depth image has its size and at least one channel, of which only the first is read. Coverage is data_depth_matte's, rounded to the nearest half float as that operation's mask holds it; the color is kept and the alpha becomes alpha × coverage, rounded to the nearest half float. The output is therefore bit for bit what data_depth_matte followed by video_apply_mask gives, without writing and reading the mask between them, so a holdout costs one read and one write of the picture. Fusion requires that no expansion, feather, inversion or mask combination intervene. Vela also requires a single multiplying depth mask, aligned with the picture at the same size and covering its full timeline range. Both backends match the engine's reference definition, passtape_engine::ops::video_depth_mask::masked, exactly.

lens_mapmedia.data.lens_map

Makes the STMap that undistorts or redistorts through one of 3DEqualizer's lens models, for stmap_warp.

ParameterMeaning
modelConstant: 0 Classic, 1 Radial Standard Degree 4, 2 and 3 Anamorphic Standard Degree 4 and 6, 4 and 5 Anamorphic Rescaled Degree 4 and 6.
directionConstant: 0 undistort, where the output is the undistorted picture and the warp's source the distorted plate; 1 redistort, where the output is the distorted frame and the source the undistorted picture.
origin_x, origin_y, frame_width, frame_heightConstant, whole pixels: the lens frame's top-left corner inside the output, that is its left and top margins, and the lens frame W × H, the raster the lens was solved on. The output's own size is set when the operation is added.
filmback_width, filmback_height, pixel_aspect, lens_centre_x, lens_centre_yKeyframable: 3DE's virtual filmback in millimetres, the solve raster's pixel aspect, and the lens centre's offset in millimetres with y up.
field_of_view_left, _right, _bottom, _topKeyframable: 3DE's field of view xa, xb, ya and yb in unit coordinates.
coefficient_0 … coefficient_21Keyframable, by model. Classic: distortion, anamorphic squeeze, curvature x, curvature y, quartic distortion. Radial: c2, u2, v2, c4, u4, v4, phi in degrees, b. Anamorphic: cx02, cx22, cx04, cx24, cx44, cx06, cx26, cx46, cx66, the same nine for cy, lens rotation in degrees, squeeze x, squeeze y, rescale. Degree 4 models ignore the degree 6 terms and standard ones the rescale; slots past a model's own hold 0.

It has no inputs. The output is an Rg32Float data image of map values in the lens frame's unit coordinates, as Nuke's STMap reads them: (0, 0) is the frame's bottom-left corner and (1, 1) its top-right, and values beyond them point into a margin. Output pixel (i, j) stands at frame position x = i − origin_x + 0.5, y = j − origin_y + 0.5, unit point p = (x / W, 1 − y / H). A redistort map holds the undistorted point of p. An undistort map holds the distorted point whose undistorted point is p, if it lies in the lens frame; where none does, both channels hold the finite marker −3.0e38, never NaN. The definition is passtape_engine::ops::data_lens_map::value, from passtape-lens in f64. Kernels evaluate the model in f32: an undistort map starts from an inverse table solved on the CPU, one point per table step of output pixels, the largest power of two from 4 to 32 that puts at least 128 cells across the lens frame's longer side, so 32 at 4K. It takes one Newton step, and a second, at most one table step long, where the residual is above 0.01 px, writing the marker if it still is. Both backends stay within 0.002 px of the definition and of each other. A map whose parameters are all constant is a static value: it is computed once and reused at every time.

stmap_warpmedia.video.stmap_warp

Resamples a color image through an STMap, a data image of source positions, following Nuke's STMap convention.

ParameterMeaning
filterConstant: 0 cubic (the default, as in Nuke), 1 bilinear, 2 nearest.
edgesConstant: 0 transparent (the default), where a texel outside the source reads as zero in every channel; 1 clamp, where it reads as the nearest edge texel.
window_x, window_y, window_width, window_heightConstant: the source's display window inside the source surface, in pixels. A source with an overscan margin has the window inset in it, and one whose pixels cover only part of its display window has a negative origin; otherwise the window is the whole surface.
offset_x, offset_yConstant whole pixels, 0 by default: where the map's first pixel lands in a placed warp's larger output. A placed warp writes straight into its owner's frame, such as a picture with an overscan margin, instead of being placed there by another pass.

The map is a lookup from output to source: output pixel p reads (u, v) from the map's first two channels at p, and the map needs at least two channels. u runs 0 to 1 left to right across the display window and v runs 0 to 1 bottom to top, so the source point is x = window_x + u·W and y = window_y + (1 − v)·H in source-surface pixels, with W × H the window's size. Source points snap to the nearest 1/1024 pixel, ties to even, so identity maps are exact. UVs outside 0 to 1 reach the overscan margin where the surface has one, and the edge mode beyond it. Pixel (i, j) covers [i, i + 1) × [j, j + 1) with y down, so an identity map holds ((i + 0.5) / W, 1 − (j + 0.5) / H) and reproduces the source exactly. Nearest reads texel (⌊x⌋, ⌊y⌋) unchanged. Bilinear and cubic start from tx = x − 0.5, i0 = ⌊tx⌋, fx = tx − i0: bilinear weights texels i0 and i0 + 1 by 1 − fx and fx, and cubic weights i0 − 1 to i0 + 2 with the Mitchell–Netravali kernel for B = 0, C = 0, Nuke's Cubic as its documentation gives it, which is zero from one texel out. Preparation converts the source to the linear working color (linear BT.2020, straight alpha, Rgba16Float) first, so the warp always filters in linear light, as Nuke does. It is filtered premultiplied: each tap adds (r·a, g·a, b·a, a) times its weight, the output alpha is the summed alpha clamped to 0 to 1, and the color is the summed color divided by the summed alpha. Edges between opaque and transparent pixels therefore keep their color rather than darkening. A non-finite UV gives a transparent pixel, and so does a map pixel whose u is the invalid marker −3.0e38 (video_stmap_warp::INVALID_U), checked before any arithmetic; lens maps write it where no source is valid, since WGSL may assume NaN never occurs. With every filter, a pixel whose alpha is NaN or no more than 2−25, which rounds to half-float zero, is (0, 0, 0, 0), so the color is zero wherever the output alpha is. The output has the map's size, or for a placed warp the size its graph gives, with the map's pixels at the offset and every output pixel outside them (0, 0, 0, 0). It is in that working color with straight alpha, as Rgba16Float rounded to the nearest half float; the source keeps its own size. A warp whose source and map are both static values is one too. Both backends match the engine's reference definition, passtape_engine::ops::video_stmap_warp::warped, within one half-float ULP, and exactly for nearest and identity warps.

Analysis

video_scopesmedia.video.scopes

Computes histogram, waveform, RGB parade, and vectorscope tensors from one GPU image traversal.

Input before video_scopesResult of video_scopes

Tracking

Tracking follows something across a series of video frames. Use it to attach a mask to a moving face, keep a graphic pinned to a sign, or measure camera motion for stabilization.

Passtape supports three tracking results:

  • Object bounds for power windows and other rectangular selections.
  • Four independent corners for perspective-aware corner pins.
  • Whole-frame camera motion for stabilization.

Track an object

Choose the object on one seed frame, provide the ordered frame times, and load each frame when Passtape asks for it. Bounds use normalized [x, y, width, height] coordinates.

use passtape::{CancellationToken, RationalTime};
use passtape_tracking::{
    TrackRequest, TrackSeed, TrackingDirection, TrackingQuality,
    TrackingResult, track,
};

let request = TrackRequest {
    seed_time: RationalTime::from_integer(3),
    seed: TrackSeed::Bounds([0.30, 0.20, 0.25, 0.40]),
    direction: TrackingDirection::Both,
    quality: TrackingQuality::Accurate,
    minimum_confidence: 0.5,
};

let result = track(
    &frame_times,
    |index| load_pixel_buffer(index),
    request,
    &CancellationToken::new(),
    |progress| update_progress(progress),
)?;

let TrackingResult::Bounds(bounds) = result else {
    unreachable!("a bounds seed returns a bounds track");
};
let curves = bounds.to_power_window_keyframes()?;

let translation = graph.add_keyframed_parameter(
    "window-translation",
    curves.translation,
)?;
let scale = graph.add_keyframed_parameter(
    "window-scale",
    curves.scale,
)?;
let rotation = graph.add_keyframed_parameter(
    "window-rotation",
    curves.rotation,
)?;

Use those three parameters in video_power_window. For perspective tracking, use TrackSeed::Quadrilateral; its result converts with to_corner_pin_keyframes() and connects to video_corner_pin.

frame_times, load_pixel_buffer, and update_progress belong to the application. This keeps file decoding and progress UI under the application’s control.

Track camera motion

Camera tracking measures how the whole image moves between frames.

use passtape::CancellationToken;
use passtape_tracking::track_camera_motion;

let motion = track_camera_motion(
    &frame_times,
    |index| load_pixel_buffer(index),
    &CancellationToken::new(),
    |progress| update_progress(progress),
)?;

Pass the resulting motion track to the stabilization solver or use its samples in a custom camera-motion workflow.

Measured horizontal and vertical camera translation over time
Measured camera translation over the clip: horizontal in orange, vertical in blue. The steady drift is the camera's real motion; the wobble riding on each trace is the handheld shake.

Stabilization

Stabilization removes unwanted camera shake. First track the camera motion, then smooth it into ordinary transform keyframes and attach those keyframes to the video graph.

use passtape::{RationalTime, ops::video_transform_2d};
use passtape_stabilization::{
    StabilizationOptions, stabilize,
};

let curves = stabilize(
    &motion,
    [1920, 1080],
    StabilizationOptions {
        smoothing_radius: RationalTime::new(1, 2)?,
        maximum_zoom: 1.25,
    },
)?;

let translation_x = graph.add_keyframed_parameter(
    "stabilize-x",
    curves.translation_x,
)?;
let translation_y = graph.add_keyframed_parameter(
    "stabilize-y",
    curves.translation_y,
)?;
let scale = graph.add_keyframed_parameter(
    "stabilize-scale",
    curves.scale,
)?;
let rotation = graph.add_keyframed_parameter(
    "stabilize-rotation",
    curves.rotation_degrees,
)?;
let zero = graph.add_scalar_parameter("stabilize-zero", 0.0)?;
let center = graph.add_scalar_parameter("stabilize-center", 0.5)?;

let stabilized = graph.add_operation(video_transform_2d::Options {
    id: "stabilize",
    active_range: source_info.full_range(),
    input: source,
    translation_x,
    translation_y,
    scale_x: scale,
    scale_y: scale,
    rotation_degrees: rotation,
    anchor_x: center,
    anchor_y: center,
    crop_left: zero,
    crop_top: zero,
    crop_right: zero,
    crop_bottom: zero,
})?;

The smoothing radius controls how much camera movement is removed; the example’s RationalTime::new(1, 2) averages motion over a half-second window. A larger radius produces steadier motion but can require more zoom to hide moving frame edges. maximum_zoom sets the largest crop the application will accept.