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
retimeCuts, offsets, reverses, freezes, or changes the speed of audio or video by mapping output time to input time.
text_renderRenders semantic text as premultiplied-alpha video so it can be transformed and composited like any other visual layer.


Audio
audio_mixmedia.audio.mixAdds 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_panApplies sample-accurate volume and stereo pan controls.
| Parameter | Meaning |
|---|---|
gain | Linear amplitude from 0 to 64; 1 is unity gain. |
pan | Stereo position from full left (-1) through full right (1). |
audio_normalizemedia.audio.normalizeApplies the constant gain calculated by Passtape's whole-program loudness analysis.
| Parameter | Meaning |
|---|---|
gain | Constant 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.eqApplies one high-pass, low-pass, peaking, low-shelf, or high-shelf filter band. Chain several nodes to build a multiband EQ.
| Parameter | Meaning |
|---|---|
kind | Filter kind: 0 high-pass, 1 low-pass, 2 peaking, 3 low-shelf, 4 high-shelf. |
frequency_hz | Filter cutoff or center frequency, from 10 to 96,000 Hz. |
gain_db | Signed boost or cut for peaking and shelf kinds, from -48 to 48 dB. |
q | Resonance or bandwidth as filter Q, from 0.1 to 18. |
audio_gatemedia.audio.gateReduces audio below a threshold, with attack, hold, release, range, and hysteresis controls.
| Parameter | Meaning |
|---|---|
threshold_db | Level below which the gate closes, from -120 to 0 dB. |
hysteresis_db | Extra level required to reopen a closed gate, from 0 to 48 dB. |
attack_ms, hold_ms, release_ms | Time to open, minimum time held open, and time to close, each from 0 to 10,000 ms. |
range_db | Attenuation applied when fully closed, from 0 to 120 dB. |
audio_compressormedia.audio.compressorReduces dynamic range above a threshold using ratio, knee, attack, release, and makeup gain controls.
| Parameter | Meaning |
|---|---|
threshold_db | Level where gain reduction begins, from -120 to 0 dB. |
ratio | Slope above the threshold, from 1 to 100; 1 disables compression. |
knee_db | Width of the soft transition around the threshold, from 0 to 48 dB. |
attack_ms, release_ms | Gain-reduction attack and release times, each from 0 to 10,000 ms. |
makeup_gain_db | Gain applied after compression, from -48 to 48 dB. |
audio_limitermedia.audio.limiterPrevents peaks from exceeding a ceiling while preserving quieter material.
| Parameter | Meaning |
|---|---|
ceiling_dbfs | Maximum sample peak, from -60 to 0 dBFS. |
release_ms | Time over which gain recovers after a peak, from 0 to 10,000 ms. |
Video composition and geometry
video_depth_defocusmedia.video.depth_defocusDefocuses 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.
| Parameter | Meaning |
|---|---|
image, depth | Straight-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_radius | Focus distance in metres, radius at infinity, and an intentional 0–32 vertical-source-pixel radius cap. These optical controls may be animated. |
near, far | Constant switches enabling blur closer than and farther than focus. |
fill, fill_reach | Constant estimated-background-fill switch and donor reach of 0–32 vertical source pixels. Fill cannot recover hidden geometry. |
encoding, metres_per_unit | 0: 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_y | Fixed 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_threshold | Optional raw finite-background sentinel: distance at/above the threshold, or reciprocal depth at/below it, means infinity. Invalid negative or NaN values remain invalid. |
view | Constant 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.gaussianApplies a keyframeable Gaussian blur with a radius measured in pixels.


| Parameter | Meaning |
|---|---|
radius | Scalar — 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_overPlaces premultiplied-alpha foreground video over background video.


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.opacityChanges a video's alpha uniformly from fully transparent to fully opaque.


| Parameter | Meaning |
|---|---|
opacity | Scalar — 0 is fully transparent and 1 leaves the input unchanged. |
video_mixmedia.video.mixInterpolates between two video inputs using a keyframeable mix amount.


| Parameter | Meaning |
|---|---|
amount | Scalar — 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.transitionTransitions between outgoing and incoming video using dissolve, dip-to-black, or directional wipe modes.


| Parameter | Meaning |
|---|---|
kind | Integral 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. |
progress | Reveal progress from 0 (outgoing frame) to 1 (incoming frame), normally keyframed across the range. |
video_blendmedia.video.blendComposites a foreground layer with opacity and normal, add, multiply, or screen blend modes.


| Parameter | Meaning |
|---|---|
opacity | Foreground opacity from 0 to 1. |
mode | Integral blend mode: 0 normal, 1 add, 2 multiply, 3 screen. |
video_corner_pinmedia.video.corner_pinPerspective-maps a frame to four independently keyframeable destination corners.


| Parameter | Meaning |
|---|---|
top_left, top_right, bottom_right, bottom_left | Point2 — 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.fillReplaces the pixels a hole mask selects with pixels spread in from around it.
| Parameter | Meaning |
|---|---|
reach | How far from the hole donor pixels may lie, in pixels. |
grain | Standard deviation of deterministic noise added per frame. |
regions | Up 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_2dTranslates, scales, rotates, anchors, and crops video in one operation.


| Parameter | Meaning |
|---|---|
translation_x, translation_y | Movement in output pixels. |
scale_x, scale_y | Independent scale; negative values flip an axis. |
rotation_degrees | Clockwise rotation in degrees. |
anchor_x, anchor_y | Scale and rotation pivot in normalized source coordinates; 0.5 is center. |
crop_left, crop_top, crop_right, crop_bottom | Normalized 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_adjustAdjusts exposure, contrast, saturation, white-balance temperature and tint, vignette, and sharpening.


| Parameter | Meaning |
|---|---|
exposure | Brightness from -20 to 20 stops; 1 doubles linear light. |
contrast | Contrast from 0 to 4 around middle gray; 1 leaves it unchanged. |
saturation | Color intensity from 0 to 4; 0 is grayscale and 1 leaves it unchanged. |
temperature | Blue-to-amber white balance from -1 to 1; 0 leaves it unchanged. |
tint | Green-to-magenta white balance from -1 to 1; 0 leaves it unchanged. |
vignette | Edge-darkening strength from 0 to 1. |
sharpen | Unsharp-mask strength from 0 to 2. |
window_x, window_y, window_width, window_height | Constant 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_gradeApplies lift, gamma, gain, offset, contrast, pivot, saturation, temperature, and tint, optionally through a mask.


| Parameter | Meaning |
|---|---|
lift_r, lift_g, lift_b | Per-channel lift, from -4 to 4. |
gamma_r, gamma_g, gamma_b | Per-channel gamma multiplier, from 0.01 to 10. |
gain_r, gain_g, gain_b | Per-channel gain, from 0 to 16. |
offset_r, offset_g, offset_b | Per-channel additive offset, from -4 to 4. |
exposure | Exposure from -20 to 20 stops. |
contrast | Contrast multiplier from 0 to 4. |
pivot | Contrast pivot in normalized linear RGB, from 0 to 1. |
saturation | Saturation multiplier from 0 to 4. |
temperature | Blue-to-amber white balance from -1 to 1. |
tint | Green-to-magenta white balance from -1 to 1. |
video_color_curvemedia.video.color.curveApplies a master transfer curve to the image, optionally through a mask.


| Parameter | Meaning |
|---|---|
strength | Curve blend strength from 0 (bypass) to 1 (full effect). |
video_rgb_curvesmedia.video.color.rgb_curvesApplies master and per-channel red, green, and blue transfer curves, optionally through a mask.


| Parameter | Meaning |
|---|---|
strength | Curve blend strength from 0 (bypass) to 1 (full effect). |
video_channel_mixermedia.video.color.channel_mixerRemaps output RGB channels through a keyframeable three-by-three matrix, optionally through a mask.


| Parameter | Meaning |
|---|---|
red_from_red … blue_from_blue | The nine row-major matrix coefficients mapping input RGB to output RGB, each from -4 to 4. |
red_offset, green_offset, blue_offset | Additive output-channel offsets, each from -4 to 4. |
strength | Mixer blend strength from 0 (bypass) to 1 (full effect). |
video_hue_curvemedia.video.color.hue_curveChanges hue, luminance, or saturation as a function of a selected color property, optionally through a mask.


| Parameter | Meaning |
|---|---|
strength | Curve blend strength from 0 (bypass) to 1 (full effect). |
video_color_lut_3dmedia.video.color.lut_3dApplies a three-dimensional RGB lookup table, with optional masked strength.


| Parameter | Meaning |
|---|---|
strength | LUT blend strength from 0 (bypass) to 1 (full effect). |
video_tone_mapmedia.video.tone_mapMaps HDR luminance into a target display range while preserving color and highlight detail.


| Parameter | Meaning |
|---|---|
source_peak_nits | Declared source mastering peak, from 100 to 10,000 nits. |
target_peak_nits | Target 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.maskConverts the red channel of a video matte into first-class mask data.


video_hsl_qualifiermedia.video.color.hsl_qualifierBuilds complementary inside and outside masks by selecting ranges of hue, saturation, and luminance.


video_chroma_keymedia.video.key.chromaKeys a selected color and returns complementary foreground and background masks.


| Parameter | Meaning |
|---|---|
key_color | RGB — key color in linear BT.2020 RGB. |
tolerance | Chroma distance accepted as background coverage, from 0 to 1. |
softness | Additional chroma-distance transition width, from 0 to 1. |
video_luma_keymedia.video.key.lumaBuilds foreground and background masks from a luminance range.


| Parameter | Meaning |
|---|---|
minimum, maximum | Selected luminance bounds, each from 0 to 1. |
softness | Transition width outside both luminance bounds, from 0 to 1. |
video_power_windowmedia.video.color.power_windowCreates a geometric grading mask whose translation, scale, and rotation can be keyframed or driven by tracking data.

| Parameter | Meaning |
|---|---|
translation | Point2 — translation in normalized image coordinates. |
scale | Point2 — nonuniform scale relative to the authored window. |
rotation | Clockwise rotation in radians. |
mask_levelsmedia.mask.levelsRemaps mask coverage to adjust its black point, white point, and gamma.
| Parameter | Meaning |
|---|---|
black_point | Input coverage mapped to 0, from 0 to 1. |
white_point | Input coverage mapped to 1, from 0 to 1. |
gamma | Midtone exponent from 0.01 to 10; 1 preserves a linear ramp. |
mask_mattemedia.mask.matteTurns a picture's alpha, luminance or HSL key into mask coverage, times its alpha.
| Parameter | Meaning |
|---|---|
source | Constant: 0 alpha, 1 luminance, 2 key. |
hue_low … luminance_softness | The key's nine ranges from 0 to 1, as the HSL qualifier's, but animatable; read only by the key. |
mask_morphologymedia.mask.morphologyExpands or contracts a mask spatially.
| Parameter | Meaning |
|---|---|
radius | Signed radius in pixels from -64 to 64; positive expands and negative contracts, resolved to the nearest whole pixel. |
mask_blurmedia.mask.blurSoftens mask edges with a Gaussian blur.
| Parameter | Meaning |
|---|---|
radius | Gaussian radius in pixels, from 0 to 64. |
video_despillmedia.video.key.despillRemoves color spill aligned with a chroma-key color inside a mask.


| Parameter | Meaning |
|---|---|
key_color | RGB — key color in linear BT.2020 RGB. |
amount | Suppression amount from 0 (unchanged) to 1 (full neutralization). |
video_apply_maskmedia.video.apply_maskMultiplies a video's alpha by mask coverage.


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.combineCombines two masks with pointwise mask algebra.
| Parameter | Meaning |
|---|---|
mode | Integral mode: 0 intersect, 1 union, 2 subtract, 3 xor. |
mask_previewmedia.mask.previewConverts a mask into grayscale video for display or debugging.


Data images
data_rangemedia.data.rangeMeasures 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.previewShows a data image as an opaque picture for display, without changing its stored values.
| Parameter | Meaning |
|---|---|
mode | Constant: 0 grey (first channel), 1 channels (up to three as RGB), 2 IDs. |
min, max | Finite 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_matteMakes a mask from a depth image, covering what lies between two depths, for depth holdouts.
| Parameter | Meaning |
|---|---|
near, far | Finite depths, keyframable, between which coverage is 1. |
softness | Finite and at least 0, keyframable: the width of the linear ramp outside near and far. 0 gives a hard edge. |
encoding | Constant: 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_maskMultiplies a picture's alpha by a depth matte's coverage in one pass, for a depth holdout with no edge processing.
| Parameter | Meaning |
|---|---|
near, far, softness, encoding | As 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_mapMakes the STMap that undistorts or redistorts through one of 3DEqualizer's lens models, for stmap_warp.
| Parameter | Meaning |
|---|---|
model | Constant: 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. |
direction | Constant: 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_height | Constant, 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_y | Keyframable: 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, _top | Keyframable: 3DE's field of view xa, xb, ya and yb in unit coordinates. |
coefficient_0 … coefficient_21 | Keyframable, 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_warpResamples a color image through an STMap, a data image of source positions, following Nuke's STMap convention.
| Parameter | Meaning |
|---|---|
filter | Constant: 0 cubic (the default, as in Nuke), 1 bilinear, 2 nearest. |
edges | Constant: 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_height | Constant: 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_y | Constant 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.scopesComputes histogram, waveform, RGB parade, and vectorscope tensors from one GPU image traversal.


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