@video-ultra/core
The engine without React: the project format, every edit as a function, export and devices.
npm install @video-ultra/coreFunctions
addAsset
functionRegisters an imported media file.
function addAsset(project: Project, asset: Asset): void;addCaptions
functionAdds captions to the caption row (made on first use, on top of everything). replace clears the row first (new auto captions or an imported file) — only the captions touching range when it's given (a part heard again). Captions are snapped to frames and never overlap; new ones take the row's current look (or preset for a new row). Returns the row's id.
function addCaptions(project: Project, captions: readonly CaptionInput[], ids: IdFactory, options?: {
replace?: boolean;
preset?: CaptionPreset;
range?: {
start: Time;
end: Time;
};
}): string;addMarker
functionAdds a marker at time (snapped to a frame, inside the video). Returns its id.
function addMarker(project: Project, time: Time, ids: IdFactory, label?: string): string;addToLane
functionAdds an item to a lane (text, stickers, picture-in-picture, audio) at item.start.
function addToLane(project: Project, item: Item, ids: IdFactory, trackId?: string): void;allTrackLists
functionEvery track list in the project: its own, then each combined clip's.
function allTrackLists(project: Project): Track[][];applyEditActions
functionChecks and applies actions (from a model: unknown values) to project in order. Throws an EditError naming the first bad action — run it inside one editor edit so nothing is applied then (the whole set is one undo step otherwise). Returns the number applied.
function applyEditActions(project: Project, actions: unknown[], ids: IdFactory): number;applyTemplate
functionAdds a template at at (usually the playhead): its elements as lane items, filled with values, grouped when there are several. Returns the new ids (empty when every text was left empty).
function applyTemplate(project: Project, template: TemplatePreset, values: Readonly<Record<string, string>>, at: Time, ids: IdFactory): string[];arrangeItem
functionMoves an element up or down the stack of what is on screen at t (Bring forward / Send backward / Bring to front / Send to back). Stacking follows lane order (later lanes draw on top), so the element's lane moves — or, when the lane holds other items too, the element moves to a new lane at that place and the others stay where they are. The main video is always at the back. Throws when there is nowhere to go.
function arrangeItem(project: Project, itemId: string, to: ArrangeTo, t: Time, ids: IdFactory): void;assetInUse
functionWhether any item (on the timeline or inside a combined clip) uses the asset.
function assetInUse(project: Project, assetId: string): boolean;bezierAt
functionA cubic Bézier curve's y at x (Newton steps on x(t), then bisection as a fallback).
function bezierAt(curve: Readonly<Bezier>, x: number): number;captionTrack
functionThe project's caption row, if it has one.
function captionTrack(project: Project): Track | null;captionWords
functionThe words of text as the screen shows them.
function captionWords(text: string): string[];captionWordTimes
functionEach shown word's start / end relative to the caption's start (flicks).
function captionWordTimes(item: Pick<TextItem, 'text' | 'duration' | 'words'>): CaptionWord[];checkInvariants
functionRules every project must satisfy after any edit. The edit operations keep them; the property tests prove it with random edit sequences. Returns a list of violations (empty = valid).
function checkInvariants(project: Project): string[];clearKeyframes
functionRemoves every keyframe of prop (or of all properties): the property keeps the value it has at bakeAt (flicks from the item's start) as its plain value.
function clearKeyframes(project: Project, itemId: string, prop?: KeyframeProp, bakeAt?: Time): void;combineItems
functionCombines items into one clip (a video item playing a new compound asset). Main-track clips must sit next to each other: the combined clip takes their place on the main track (the transition into the first one comes along); the selected layers inside their span go into it. Only layers: the combined clip goes on a layer at the first one's start. Captions stay out. Returns the combined clip's id.
function combineItems(project: Project, itemIds: readonly string[], ids: IdFactory, name?: string): string;compoundCycle
functionWhether combined clip assetId contains itself (directly or through another one).
function compoundCycle(project: Project, assetId: string): boolean;compoundLength
functionLength of a combined clip's content (its last item's end), at least one frame.
function compoundLength(project: Project, tracks: readonly Track[]): Time;correctionRequest
functionWhat to send the model when the editor rejected its answer (error from applyEditActions), to get a corrected one for the same instruction.
function correctionRequest(instruction: string, error: string): string;createEditor
functionCreates an editor around project.
function createEditor(project: Project, options?: EditorOptions): Editor;createProject
functionA new, empty project with one (empty) main track.
function createProject(options?: CreateProjectOptions): Project;curveAt
functionA keyframe curve's progress at 0…1.
function curveAt(ease: Ease | Readonly<Bezier> | undefined, p: number): number;deleteItem
functionDeletes an item. The main track closes the gap; empty lanes disappear.
function deleteItem(project: Project, itemId: string): void;deleteLut
functionDeletes a LUT look: every item using it (combined clips' insides too) goes back to no LUT, and the look leaves the project. Returns how many items used it. Undo brings both back (the file stays in storage).
function deleteLut(project: Project, assetId: string): number;describeProject
functionA compact, model-friendly description of project (ids, kinds, times in seconds, texts).
function describeProject(project: Project): ProjectDescription;detectCapabilities
functionDetects what the current browser and device support and suggests a DeviceTier. Runs in the browser only; takes a few milliseconds (codec checks are async).
function detectCapabilities(): Promise<Capabilities>;duplicateItem
functionDuplicates an item right after itself. Returns the new id. A locked item can be duplicated; the copy is unlocked and outside any group.
function duplicateItem(project: Project, itemId: string, ids: IdFactory): string;exportAudioBitrate
functionThe audio bitrate (bits/s) for each quality: AAC / Opus stereo.
function exportAudioBitrate(quality: ExportOptions['quality']): number;exportBitrate
functionThe video bitrate (bits/s) an export uses: set from the picture size, frame rate and quality, so the same choice gives about the same file size in every browser (encoders' own "quality" presets differed up to 4×). The export dialog's size estimate uses the same numbers.
function exportBitrate(width: number, height: number, fps: number, quality: ExportOptions['quality'], codec?: keyof typeof CODEC_FACTOR): number;exportLimits
functionAsks the browser's encoders which export resolutions work here (capped by maxExportHeight for the tier; checked as 16:9 at 30 fps). Plain WebCodecs checks, safe on the main thread; takes a few milliseconds.
function exportLimits(tier: DeviceTier): Promise<ExportLimits>;exportSize
functionOutput size: the shorter side = shortSide, the longer one keeps the project's aspect ratio.
function exportSize(projectW: number, projectH: number, shortSide: number): {
width: number;
height: number;
};fillTemplateText
functiontext with {variable}s filled from values (falling back to the template's examples).
function fillTemplateText(text: string, template: Pick<TemplatePreset, 'variables'>, values?: Readonly<Record<string, string>>): string;findAnimationPreset
functionThe preset with this id in this slot, or undefined.
function findAnimationPreset(slot: AnimationSlot, id: string): AnimationPreset | undefined;findItem
functionFinds an item and the track holding it.
function findItem(project: Project, itemId: string): {
track: Track;
item: Item;
index: number;
} | null;findTransitionPreset
functionThe preset for a stored transition type, including ids from before the library (slide-left → Push, left). Undefined for unknown ids (they play as a dissolve).
function findTransitionPreset(type: string): TransitionPreset | undefined;formatSrt
functionCues as a SubRip (.srt) file.
function formatSrt(cues: readonly SubtitleCue[]): string;formatTime
functionm:ss.cc for display, e.g. 1:04.25. Hours appear only when needed.
function formatTime(time: Time): string;formatVtt
functionCues as a WebVTT (.vtt) file.
function formatVtt(cues: readonly SubtitleCue[]): string;fps
functionFrames per second as a float (for display and encoder settings only).
function fps(rate: FrameRate): number;frameDuration
functionLength of one frame in flicks. Exact for every rate in FRAME_RATES.
function frameDuration(rate: FrameRate): Time;frameIndex
functionIndex of the frame that contains time (frames start at 0).
function frameIndex(time: Time, rate: FrameRate): number;freezeFrame
functionInserts a still frame of a main-track video at at, lasting duration (default 3 s). Returns the freeze item's id.
function freezeFrame(project: Project, itemId: string, at: Time, ids: IdFactory, duration?: Time): string;fromMicroseconds
functionMicroseconds (WebCodecs timestamps) → flicks.
function fromMicroseconds(us: number): Time;fromSeconds
functionSeconds → flicks (rounded to the nearest flick).
function fromSeconds(seconds: number): Time;groupCaptions
functionGroups words (seconds, from the start of the sound) into captions, placed at offset on the timeline. Words keep their own times; a caption runs from its first word's start to its last word's end (at least 0.4 s).
function groupCaptions(words: readonly TranscriptWord[], offset?: Time, options?: GroupOptions): GroupedCaption[];groupItems
functionGroups lane items (two or more) so they select, move and scale together. Members of other groups join the new one. Locked items can join (they still don't move). Returns the group id.
function groupItems(project: Project, itemIds: readonly string[], ids: IdFactory): string;groupOf
functionThe ids an item moves and selects with: every member of its group, or just the item itself when it isn't grouped.
function groupOf(project: Project, itemId: string): string[];hasKeyframes
functionTrue when any property has keyframes.
function hasKeyframes(keyframes: Readonly<Keyframes> | undefined): boolean;insertMain
functionAdds a video / photo / freeze item to the main track at index (default: the end).
function insertMain(project: Project, item: Item, index?: number): void;itemEnd
functionEnd of an item on the timeline.
function itemEnd(item: Item): Time;keyedTransform
functionThe transform at t (flicks from the item's start) into out (reused — no allocation): keyframed properties sampled, the rest from base. Opacity is kept in 0…1, scale above 0.
function keyedTransform(base: Readonly<Transform>, keyframes: Readonly<Keyframes> | undefined, t: Time, out: Transform): Transform;keyedValue
functionThe value of one keyed property at t (flicks from the item's start), or null if not keyed.
function keyedValue(keyframes: Readonly<Keyframes> | undefined, prop: KeyframeProp, t: Time): number | null;keyTime
functionA keyframe's time as the item sees it (flicks from its start).
function keyTime(keyframes: Readonly<Keyframes>, k: Readonly<Keyframe>): Time;lookFromPreset
functionA caption row's look from a preset.
function lookFromPreset(preset: CaptionPreset): CaptionLook;mainTrack
functionThe single main track.
function mainTrack(project: Project): Track;markCaptionChecked
functionMarks a caption as checked: the "check this" mark goes.
function markCaptionChecked(project: Project, itemId: string): void;maxExportHeight
functionHighest export resolution (shorter side) for a device tier.
function maxExportHeight(tier: DeviceTier): ExportHeight;mergeCaptionWithNext
functionJoins a caption with the next one on its row (text, time and words).
function mergeCaptionWithNext(project: Project, itemId: string): void;moveItem
functionMoves a lane item in time (and optionally to another lane of the same kind).
function moveItem(project: Project, itemId: string, start: Time, ids: IdFactory, trackId?: string): void;moveItemToNewLane
functionMoves a lane item to a brand-new lane inserted at track position atIndex (1 = right under the main track), starting at start. Returns the new track's id. The timeline uses it when a clip is dropped between lanes or where it would overlap.
function moveItemToNewLane(project: Project, itemId: string, start: Time, ids: IdFactory, atIndex: number): string;moveKeyframe
functionMoves a keyframe of prop from from to to (and to value, when given).
function moveKeyframe(project: Project, itemId: string, prop: KeyframeProp, from: Time, to: Time, value?: number): void;moveLaneToMain
functionPuts a picture from an overlay lane into the main sequence at position toIndex (the clips after it move later). Stickers can't join the main track.
function moveLaneToMain(project: Project, itemId: string, toIndex: number): void;moveMainToLane
functionLifts a main-track clip onto a brand-new overlay lane at track position atIndex, starting at start: the clip becomes a layer over the video, and the main track closes the gap. A clip still at full-frame size shrinks to LAYER_SCALE so it shows as an element (and its own animation, filter and so on visibly apply to it alone). Returns the new lane's id.
function moveMainToLane(project: Project, itemId: string, start: Time, ids: IdFactory, atIndex: number): string;parseProject
functionOpens a project from untrusted JSON (a saved file, the host's database, a crash-recovery snapshot): migrates old versions, validates the shape, and repairs broken timing so a damaged file still opens. Never throws.
function parseProject(input: unknown, ids?: IdFactory): ParseResult;parseSubtitles
functionReads SRT or VTT text into cues (in time order; empty and broken cues are skipped).
function parseSubtitles(text: string): SubtitleCue[];pasteItems
functionPastes copied items at at (usually the playhead), keeping their timing relative to each other. Copies get new ids; groups stay groups (as new groups). Clips copied from the main video go back into it, after the clip under at; everything else goes to a lane. Media the project doesn't have yet (copied from another project) is added from assets. Returns the new ids, in the order given.
function pasteItems(project: Project, copied: readonly CopiedItem[], assets: Readonly<Record<string, Asset>>, at: Time, ids: IdFactory): string[];pitchRatio
functionHow much the pitch-shifter raises the pitch: the semitones asked for and, with keepPitch, the inverse of the speed (clamped to 0.5×…2×, where a shifter still sounds natural).
function pitchRatio(fx: AudioFx | undefined, speed: number): number;presetFits
functionTrue when a project of width × height already has the preset's frame shape (within 1%).
function presetFits(preset: ExportPreset, width: number, height: number): boolean;projectDuration
functionTotal length of the project: the end of the last item on any track.
function projectDuration(project: Project): Time;projectFrame
functionOne frame of the project's frame rate, in flicks.
function projectFrame(project: Project): Time;randomId
functionRandom 12-character base-36 ids (≈ 62 bits).
const randomId: IdFactory;refreshCompound
functionAfter the inside of combined clip assetId changed: its length and sound follow the content, and clips that play it are shortened if they now read past its end.
function refreshCompound(project: Project, assetId: string): void;relinkAsset
functionPoints an asset at a new copy of its file (the person picked it again because the old one was moved, deleted or cleared from the device). Items keep their times; only where the bytes live and their size change.
function relinkAsset(project: Project, assetId: string, source: Asset['source'], size: number): void;removeAsset
functionRemoves a media file that no item uses any more.
function removeAsset(project: Project, assetId: string): void;removeKeyframe
functionRemoves the keyframe of prop at t (if there is one).
function removeKeyframe(project: Project, itemId: string, prop: KeyframeProp, t: Time): void;removeMarker
functionRemoves a marker.
function removeMarker(project: Project, markerId: string): void;renameAsset
functionRenames an asset (a LUT look, a media file): trimmed, at most 200 characters. An empty name keeps the old one.
function renameAsset(project: Project, assetId: string, name: string): void;renameProject
functionRenames the project.
function renameProject(project: Project, name: string): void;reorderMain
functionMoves a main-track item to a new position in the sequence.
function reorderMain(project: Project, itemId: string, toIndex: number): void;repairProject
functionFixes timing problems in place: drops items whose media is gone, re-packs the main track, moves overlapping lane items to new lanes, removes empty lanes. Returns what it changed.
function repairProject(project: Project, ids?: IdFactory): string[];replayLog
functionRebuilds a project from a snapshot plus the log entries written after it (crash recovery). Entries with seq ≤ snapshotSeq are skipped.
function replayLog(snapshot: Project, snapshotSeq: number, entries: readonly LogEntry[]): Project;resolveExportRange
functionThe part of a duration-long timeline an export covers: range clamped to the timeline, or all of it. Returns null when the range is empty after clamping.
function resolveExportRange(range: ExportRange | undefined | null, duration: Time): ExportRange | null;retimeKeyframes
functionKeyframes for a part of the item that starts offset later in its old timing (split, trim from the start): the same keyframes, shifted, so the part plays its share of the motion exactly — even inside a curve.
function retimeKeyframes(keyframes: Readonly<Keyframes>, offset: Time): Keyframes;rollEdit
functionRoll edit: moves the cut between an item and the one right after it (touching, same track) by delta — one gets longer, the other shorter by the same amount, so nothing else moves. Clamped to the media both have and to one frame each. Returns the applied delta.
function rollEdit(project: Project, itemId: string, delta: Time): Time;sampleKeyframes
functionThe value of keyframes at t (flicks from the item's start). list is in time order.
function sampleKeyframes(list: readonly Keyframe[], t: Time): number;separateItem
functionPuts a combined clip's pieces back on the timeline where it plays them (its trim and speed applied to them; its own look, size and sound settings don't carry over). Pieces get new ids, so another clip playing the same combined clip keeps it. Returns the new items' ids.
function separateItem(project: Project, itemId: string, ids: IdFactory): string[];sequentialIds
functionDeterministic ids for tests: id1, id2, …
function sequentialIds(prefix?: string): IdFactory;setAnimation
functionSets (or clears, with null) one animation of a lane item — text, sticker or picture-in-picture video / photo: its entrance (in), exit (out) or repeating loop. Entrance and exit lengths are snapped to frames and clamped to the item (the slot being set wins: the other one is shortened so they never overlap); loop speed is clamped to 0.25–4. Unknown preset ids are stored as given (they play as nothing).
function setAnimation<S extends 'in' | 'out' | 'loop'>(project: Project, itemId: string, slot: S, value: (S extends 'loop' ? AnimationLoop : AnimationClip) | null): void;setBackground
functionSets what shows behind the main track (colour or blurred video).
function setBackground(project: Project, background: Background): void;setCanvasSize
functionChanges the canvas size (aspect ratio). Item positions are relative, so layouts follow.
function setCanvasSize(project: Project, width: number, height: number): void;setCaptionLook
functionRestyles all captions (they share one look).
function setCaptionLook(project: Project, patch: CaptionLookPatch): void;setCaptionText
functionChanges one caption's text; its word times stay when the words still line up.
function setCaptionText(project: Project, itemId: string, text: string): void;setExportRange
functionSets (or clears, with null) the part of the timeline to export — the in / out points. Times are rounded to whole flicks; the range must not be empty. It isn't clamped to the video's length here (edits may shorten the video later); exports clamp it.
function setExportRange(project: Project, range: {
start: Time;
end: Time;
} | null): void;setItemFlags
functionLocks (can be selected, not moved or edited) or hides (not drawn) an item. Works on locked items — it's how they are unlocked.
function setItemFlags(project: Project, itemId: string, flags: {
locked?: boolean;
hidden?: boolean;
}): void;setKeyframe
functionSets a keyframe of prop at t (flicks from the item's start, snapped to a frame and kept inside the item): replaces one there, else adds one. The first keyframe of a property makes it follow its keyframes instead of the transform.
function setKeyframe(project: Project, itemId: string, prop: KeyframeProp, t: Time, value: number, ease?: Ease | Bezier): void;setKeyframeEase
functionSets the curve from the keyframe of prop at t to the next (null: the default).
function setKeyframeEase(project: Project, itemId: string, prop: KeyframeProp, t: Time, ease: Ease | Bezier | null): void;setSpeed
functionChanges playback speed; the item gets shorter or longer on the timeline.
function setSpeed(project: Project, itemId: string, speed: number, ids: IdFactory): void;setTrackFlags
functionMutes, hides or locks a track.
function setTrackFlags(project: Project, trackId: string, flags: Partial<Pick<Track, 'muted' | 'hidden' | 'locked'>>): void;setTransformAt
functionSets an item's transform as it should look at timeline time at (the playhead): keyframed properties get a keyframe there (added, or changed to the new value); the others change for the whole item, as without keyframes. What stage drags, sliders and align use.
function setTransformAt(project: Project, itemId: string, transform: Readonly<Transform>, at: Time): void;setTransition
functionSets (or clears, with null) the transition into an item from the one before it: on the main track, or on a layer where the two pictures touch.
function setTransition(project: Project, itemId: string, transition: Transition | null): void;shapeCoverage
functionHow much of a point shows (0…1) for a mask: x, y in the picture's box (−1…1, y down), the box's width / height, edge the anti-aliasing width in shape units, feather 0…1.
function shapeCoverage(p: Readonly<ShapePreset>, qx: number, qy: number, boxAspect: number, edge: number, feather: number, invert: boolean): number;shapeDistance
functionSigned distance from the shape's edge at (x, y) — negative inside. Coordinates: the shape's own space (y down), where proportional shapes fit the unit circle and stretched shapes fill ±aspect × ±1. Same maths as the shader.
function shapeDistance(p: Readonly<ShapePreset>, x: number, y: number, aspect?: number): number;shapePreset
functionThe shape preset with this id, or undefined.
function shapePreset(id: string): ShapePreset | undefined;shiftItems
functionMoves several lane items in time by the same amount — a group, or a selection dragged together. Clamped so none starts before 0. Each keeps its lane when it fits there (the moved items never block each other); one that would overlap a neighbour moves to a free lane of its kind. Returns the applied shift.
function shiftItems(project: Project, itemIds: readonly string[], delta: Time, ids: IdFactory): Time;slideItem
functionSlide: moves a main-video clip by delta between its neighbours — the one before gets longer (or shorter), the one after shorter (or longer); the clip itself and the video's length don't change. Returns the applied delta.
function slideItem(project: Project, itemId: string, delta: Time): Time;slipItem
functionSlip: shows a different part of a video or sound in the same place — the clip keeps its spot and length, the media slides under it by delta (flicks of timeline time; > 0 shows later media). Returns the applied delta.
function slipItem(project: Project, itemId: string, delta: Time): Time;snapToFrame
functionRounds time to the nearest frame boundary.
function snapToFrame(time: Time, rate: FrameRate): Time;sourceSpan
functionMedia items read a span of their source: [sourceIn, sourceIn + duration × speed).
function sourceSpan(item: Extract<Item, {
speed: number;
}>): Time;speechAt
functionfunction speechAt(times: readonly CaptionWord[], local: Time, out?: SpeechPosition): SpeechPosition;splitItem
functionSplits an item in two at at. Returns the id of the second part.
function splitItem(project: Project, itemId: string, at: Time, ids: IdFactory): string;splitItemAt
functionSplits an item at every time in times (timeline flicks; e.g. scene cuts) in one edit. Times outside the item or within a frame of its ends or of each other are skipped. Returns the ids of the item's parts in order (the first is itemId).
function splitItemAt(project: Project, itemId: string, times: readonly Time[], ids: IdFactory): string[];templatePreset
functionThe template with this id, or undefined.
function templatePreset(id: string): TemplatePreset | undefined;toMicroseconds
functionFlicks → microseconds (WebCodecs timestamps), rounded.
function toMicroseconds(time: Time): number;toSeconds
functionFlicks → seconds.
function toSeconds(time: Time): number;transformAt
functionAn item's transform at timeline time at (keyframes sampled; a new object).
function transformAt(item: Item, at: Time): Transform | null;trimItem
functionMoves an edge of an item by delta (positive = later on the timeline), clamped to what the media and neighbours allow. Dragging the start edge left reveals earlier media. On the main track the following items ripple; on lanes neighbours act as walls.
function trimItem(project: Project, itemId: string, edge: 'start' | 'end', delta: Time): void;ungroupItems
functionUngroups: the members become separate elements again (they stay where they are).
function ungroupItems(project: Project, groupId: string): void;updateItem
functionChanges look/sound properties of an item (transform, filter, volume, text, …).
function updateItem(project: Project, itemId: string, patch: ItemPatch): void;updateMarker
functionChanges a marker's time or label (an empty label removes it).
function updateMarker(project: Project, markerId: string, patch: {
time?: Time;
label?: string;
}): void;Classes
EditError
classAn edit that couldn't be applied. The project is unchanged.
class EditError extends Error {
readonly code: EditErrorCode;
constructor(code: EditErrorCode, message: string);
}Constants
ADJUST_KEYS
constantThe adjustment sliders (keys of item.adjust), in display order.
const ADJUST_KEYS: readonly AdjustKey[];AdjustSchema
constantEach value −1…1; 0 = unchanged. Missing = 0.
const AdjustSchema: z.ZodMiniObject<{
brightness: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
contrast: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
saturation: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
warmth: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
tint: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
highlights: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
shadows: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
sharpen: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
vignette: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
}, z.core.$strip>;ANIMATION_CATEGORIES
constantAnimation groups with their labels, in display order (AnimationPreset.category).
const ANIMATION_CATEGORIES: readonly {
readonly id: string;
readonly label: string;
}[];ANIMATION_PRESETS
constantAnimations of lane items (text, stickers, picture-in-picture): entrances, then exits (each the mirror of an entrance), then loops, each in display order.
const ANIMATION_PRESETS: readonly AnimationPreset[];AnimationClipSchema
constantOne entrance or exit animation of a lane item: a preset id and how long it plays.
const AnimationClipSchema: z.ZodMiniObject<{
type: z.ZodMiniString<string>;
duration: z.ZodMiniInt;
}, z.core.$strip>;AnimationLoopSchema
constantA repeating animation of a lane item, from its start to its end.
const AnimationLoopSchema: z.ZodMiniObject<{
type: z.ZodMiniString<string>;
speed: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
}, z.core.$strip>;AssetSchema
constantconst AssetSchema: z.ZodMiniObject<…>;AUDIO_FX_PRESETS
constantReady-made sound looks (each sets the whole effect; sliders fine-tune it).
const AUDIO_FX_PRESETS: readonly {
id: string;
fx: AudioFx;
}[];AudioFxSchema
constantSound effects on a clip's audio (file version 4+, v0.4). Every field optional; missing = off.
const AudioFxSchema: z.ZodMiniObject<{
eq: z.ZodMiniOptional<z.ZodMiniObject<{
low: z.ZodMiniNumber<number>;
mid: z.ZodMiniNumber<number>;
high: z.ZodMiniNumber<number>;
}, z.core.$strip>>;
compress: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
pitch: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
keepPitch: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
denoise: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
}, z.core.$strip>;AudioItemSchema
constantconst AudioItemSchema: z.ZodMiniObject<{
kind: z.ZodMiniLiteral<"audio">;
assetId: z.ZodMiniString<string>;
sourceIn: z.ZodMiniInt;
speed: z.ZodMiniNumber<number>;
volume: z.ZodMiniNumber<number>;
muted: z.ZodMiniBoolean<boolean>;
fadeIn: z.ZodMiniInt;
fadeOut: z.ZodMiniInt;
duck: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
audioFx: z.ZodMiniOptional<z.ZodMiniObject<{
eq: z.ZodMiniOptional<z.ZodMiniObject<{
low: z.ZodMiniNumber<number>;
mid: z.ZodMiniNumber<number>;
high: z.ZodMiniNumber<number>;
}, z.core.$strip>>;
compress: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
pitch: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
keepPitch: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
denoise: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
}, z.core.$strip>>;
id: z.ZodMiniString<string>;
start: z.ZodMiniInt;
duration: z.ZodMiniInt;
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
locked: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
hidden: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
groupId: z.ZodMiniOptional<z.ZodMiniString<string>>;
}, z.core.$strip>;BackgroundSchema
constantconst BackgroundSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
type: z.ZodMiniLiteral<"color">;
color: z.ZodMiniString<string>;
}, z.core.$strip>, z.ZodMiniObject<{
type: z.ZodMiniLiteral<"blur">;
amount: z.ZodMiniNumber<number>;
}, z.core.$strip>], "type">;BezierSchema
constantA cubic Bézier timing curve [x1, y1, x2, y2] (CSS cubic-bezier; x in 0…1).
const BezierSchema: z.ZodMiniTuple<readonly [z.ZodMiniNumber<number>, z.ZodMiniNumber<number>, z.ZodMiniNumber<number>, z.ZodMiniNumber<number>], null>;BlendModeSchema
constantHow a layer mixes with the pictures under it (file version 3+, optional; missing = normal). Lane items only — the main video is the bottom of the stack.
const BlendModeSchema: z.ZodMiniEnum<{
normal: "normal";
multiply: "multiply";
screen: "screen";
overlay: "overlay";
"soft-light": "soft-light";
add: "add";
lighten: "lighten";
darken: "darken";
difference: "difference";
}>;CAPTION_PRESETS
constantconst CAPTION_PRESETS: readonly CaptionPreset[];CaptionLookSchema
constantHow a caption row looks beyond each caption's own text style (file version 3+): the style preset it came from, and the word highlight (karaoke) as words are spoken.
const CaptionLookSchema: z.ZodMiniObject<{
preset: z.ZodMiniString<string>;
highlight: z.ZodMiniEnum<{
type: "type";
fill: "fill";
none: "none";
word: "word";
box: "box";
reveal: "reveal";
}>;
highlightColor: z.ZodMiniString<string>;
}, z.core.$strip>;CaptionWordSchema
constantOne spoken word of a caption: its text and when it's said, relative to the caption's start.
const CaptionWordSchema: z.ZodMiniObject<{
text: z.ZodMiniString<string>;
start: z.ZodMiniInt;
end: z.ZodMiniInt;
}, z.core.$strip>;ChromaKeySchema
constantGreen screen (file version 3+, optional): pixels close to color become transparent. Values 0…1: tolerance widens the range of removed colours, softness feathers the edge, spill takes the key colour's tint off what remains (green fringes on hair).
const ChromaKeySchema: z.ZodMiniObject<{
color: z.ZodMiniString<string>;
tolerance: z.ZodMiniNumber<number>;
softness: z.ZodMiniNumber<number>;
spill: z.ZodMiniNumber<number>;
}, z.core.$strip>;CropSchema
constantconst CropSchema: z.ZodMiniObject<{
left: z.ZodMiniNumber<number>;
top: z.ZodMiniNumber<number>;
right: z.ZodMiniNumber<number>;
bottom: z.ZodMiniNumber<number>;
}, z.core.$strip>;CutoutSchema
constantA picture with its background removed (file version 4+): the engine draws this image asset (same size, transparent background) instead of the item's own. The original stays, so restoring the background is removing this.
const CutoutSchema: z.ZodMiniObject<{
assetId: z.ZodMiniString<string>;
}, z.core.$strip>;DEFAULT_CAPTION_PRESET
constantThe preset new captions use.
const DEFAULT_CAPTION_PRESET: CaptionPreset;DEFAULT_TEXT_STYLE
constantconst DEFAULT_TEXT_STYLE: Readonly<TextStyle>;DEFAULT_TRANSFORM
constantconst DEFAULT_TRANSFORM: Readonly<Transform>;DirectionSchema
constantWhich way a transition (or a directional animation) moves.
const DirectionSchema: z.ZodMiniEnum<{
left: "left";
right: "right";
up: "up";
down: "down";
}>;EaseSchema
constantTiming curve of a transition: smooth (default), linear, snappy or bounce.
const EaseSchema: z.ZodMiniEnum<{
linear: "linear";
smooth: "smooth";
"ease-in": "ease-in";
"ease-out": "ease-out";
snappy: "snappy";
expo: "expo";
back: "back";
anticipate: "anticipate";
bounce: "bounce";
elastic: "elastic";
ball: "ball";
"slow-mo": "slow-mo";
steps: "steps";
}>;EDIT_ACTIONS_GUIDE
constantFor the model's instructions: what each action does.
const EDIT_ACTIONS_GUIDE = "You edit a video project for the person. Answer with JSON only:\n{\"reply\": \"<for the person>\", \"actions\": [<actions>]}.\n\"reply\" is one short sentence about what you did; when the person asks about the project (e.g. \"list\nthe media\", \"how long is it\"), answer fully in \"reply\" instead, one entry per line, using names\npeople see, never ids.\nTimes are seconds on the timeline. Use only item ids from the project description.\nWhen the person names a file, match it to \"name\" in the tracks' items (on the timeline) or in\n\"media\" (the media library); a file not on the timeline must be added before it can be edited.\n\"This\", \"it\" and \"the selected one\" mean the items in \"selection\". Change only what the person asked\nfor: touch every item only when they ask for all of them.\nActions:\n- {\"action\":\"split\",\"itemId\",\"at\"} cut a clip in two at a timeline time inside it\n- {\"action\":\"trim\",\"itemId\",\"from\"?,\"to\"?} keep only from\u2026to seconds of the clip itself (0 = its start)\n- {\"action\":\"delete\",\"itemIds\":[\u2026]}\n- {\"action\":\"move\",\"itemId\",\"start\"} text, stickers, sounds, picture-in-picture only\n- {\"action\":\"speed\",\"itemId\",\"speed\"} 0.1\u201310 (video, sound)\n- {\"action\":\"sound\",\"itemId\",\"volume\"?(0\u20132),\"muted\"?,\"fadeIn\"?,\"fadeOut\"?,\"preset\"?(catalog.soundPresets)}\n- {\"action\":\"filter\",\"itemId\",\"filter\"(catalog.filters or null),\"intensity\"?(0\u20131)}\n- {\"action\":\"adjust\",\"itemId\",\"brightness\"?,\"contrast\"?,\"saturation\"?,\"warmth\"?} each \u22121\u20261\n- {\"action\":\"transition\",\"itemId\",\"transition\"(catalog.transitions or null),\"duration\"?} into a main-video clip from the one before\n- {\"action\":\"addText\",\"ref\"?,\"text\",\"start\",\"duration\"?,\"position\"?(\"top\"|\"center\"|\"bottom\"),\"color\"?(#rrggbb),\"size\"?(\"small\"|\"medium\"|\"large\")}\n- {\"action\":\"editText\",\"itemId\",\"text\"?,\"color\"?,\"size\"?}\n- {\"action\":\"animate\",\"itemId\",\"in\"?(catalog.animationsIn or null),\"out\"?(catalog.animationsOut or null)} text, stickers and layers only, never main-video clips\n- {\"action\":\"place\",\"itemId\",\"x\"?,\"y\"?,\"scale\"?,\"rotation\"?,\"opacity\"?} position (centre; x 0 = left \u2026 1 = right, y 0 = top \u2026 1 = bottom), size (1 = as added), turn in degrees clockwise, see-through (0\u20131). Diagonal across the video from bottom-left to top-right: rotation \u221245 (top-left to bottom-right: 45), centred (x 0.5, y 0.5) and bigger (scale about 2) so it spans the frame\n- {\"action\":\"canvas\",\"ratio\"(\"9:16\"|\"16:9\"|\"1:1\"|\"4:5\"|\"4:3\"|\"21:9\")}\n- {\"action\":\"marker\",\"time\",\"label\"?}\n- {\"action\":\"rename\",\"name\"} rename the video\n- {\"action\":\"addMedia\",\"mediaId\",\"ref\"?,\"start\"?,\"asLayer\"?} put a \"media\" file on the timeline: a sound on a sound lane at start; a video / photo into the main video before the clip at start (at the end without start), or on a layer at start with asLayer:true\nTo edit something you add in the same answer, give it a \"ref\" (e.g. \"new1\") and use that as the\nitemId in the actions after it.\nTo make main-video clips flow (\"smoother\", \"more polished\"), use transitions between them.\nIf the request is unclear or impossible, return no actions and ask or explain in \"reply\".";EditActionSchema
constantThe actions a model may ask for. Times are seconds on the timeline unless said otherwise.
const EditActionSchema: z.ZodMiniDiscriminatedUnion<…>;EQ_BANDS
constantThe equaliser's band frequencies (Hz).
const EQ_BANDS: {
readonly low: 120;
readonly mid: 1000;
readonly high: 8000;
};EXPORT_HEIGHTS
constantAll export heights, smallest first.
const EXPORT_HEIGHTS: readonly ExportHeight[];EXPORT_PRESETS
constantReady-made export settings: vertical 9:16, widescreen 16:9 and square 1:1, all 1080p MP4. A preset doesn't reshape the picture: when the project's frame shape differs, the editor offers to change the canvas (an undoable edit) and otherwise exports the project's own shape.
const EXPORT_PRESETS: readonly ExportPreset[];FILTER_CATEGORIES
constantFilter groups with their labels, in display order.
const FILTER_CATEGORIES: readonly {
readonly id: FilterCategory;
readonly label: string;
}[];FILTER_PRESETS
constantColour filters for video, photo and freeze clips, in display order (grouped by category; the first 16 ids shipped in v0.1). "No filter" is not in the list: it is item.filter = null.
const FILTER_PRESETS: readonly FilterPreset[];FilterSchema
constantconst FilterSchema: z.ZodMiniObject<{
id: z.ZodMiniString<string>;
intensity: z.ZodMiniNumber<number>;
}, z.core.$strip>;FLICKS_PER_SECOND
constantFlicks per second.
const FLICKS_PER_SECOND = 705600000;FONT_PRESETS
constantText styles, in display order. Only system and generic font stacks, so text looks right offline and costs no downloads; each platform shows its closest installed face.
const FONT_PRESETS: readonly FontPreset[];FRAME_RATES
constantCommon frame rates.
const FRAME_RATES: {
readonly fps23976: {
readonly num: 24000;
readonly den: 1001;
};
readonly fps24: {
readonly num: 24;
readonly den: 1;
};
readonly fps25: {
readonly num: 25;
readonly den: 1;
};
readonly fps2997: {
readonly num: 30000;
readonly den: 1001;
};
readonly fps30: {
readonly num: 30;
readonly den: 1;
};
readonly fps50: {
readonly num: 50;
readonly den: 1;
};
readonly fps5994: {
readonly num: 60000;
readonly den: 1001;
};
readonly fps60: {
readonly num: 60;
readonly den: 1;
};
};FrameRateSchema
constantconst FrameRateSchema: z.ZodMiniObject<{
num: z.ZodMiniInt;
den: z.ZodMiniInt;
}, z.core.$strip>;FreezeItemSchema
constantA still frame taken from a video at sourceTime.
const FreezeItemSchema: z.ZodMiniObject<…>;ImageItemSchema
constantconst ImageItemSchema: z.ZodMiniObject<…>;ItemAnimationSchema
constantEntrance (in), exit (out) and repeating (loop) animations of a lane item (text, sticker, picture-in-picture video / photo). Played from the item's own time, in preview and export.
const ItemAnimationSchema: z.ZodMiniObject<{
in: z.ZodMiniOptional<z.ZodMiniObject<{
type: z.ZodMiniString<string>;
duration: z.ZodMiniInt;
}, z.core.$strip>>;
out: z.ZodMiniOptional<z.ZodMiniObject<{
type: z.ZodMiniString<string>;
duration: z.ZodMiniInt;
}, z.core.$strip>>;
loop: z.ZodMiniOptional<z.ZodMiniObject<{
type: z.ZodMiniString<string>;
speed: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
}, z.core.$strip>>;
}, z.core.$strip>;ItemSchema
constantconst ItemSchema: z.ZodMiniDiscriminatedUnion<…>;KEYFRAME_PROPS
constantProperties that take keyframes (the transform's).
const KEYFRAME_PROPS: readonly ["x", "y", "scale", "rotation", "opacity"];KeyframeSchema
constantconst KeyframeSchema: z.ZodMiniObject<{
t: z.ZodMiniInt;
v: z.ZodMiniNumber<number>;
ease: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
linear: "linear";
smooth: "smooth";
"ease-in": "ease-in";
"ease-out": "ease-out";
snappy: "snappy";
expo: "expo";
back: "back";
anticipate: "anticipate";
bounce: "bounce";
elastic: "elastic";
ball: "ball";
"slow-mo": "slow-mo";
steps: "steps";
}>, z.ZodMiniTuple<readonly [z.ZodMiniNumber<number>, z.ZodMiniNumber<number>, z.ZodMiniNumber<number>, z.ZodMiniNumber<number>], null>]>>;
}, z.core.$strip>;KeyframesSchema
constantconst KeyframesSchema: z.ZodMiniObject<…>;LAYER_SCALE
constantSize a full-frame clip takes when it becomes a layer, so it reads as an element over the video.
const LAYER_SCALE = 0.6;LutRefSchema
constantA 3D LUT look (file version 3+, optional): a .cube file stored as a lut asset, applied after the filter and adjustments, mixed in by intensity.
const LutRefSchema: z.ZodMiniObject<{
assetId: z.ZodMiniString<string>;
intensity: z.ZodMiniNumber<number>;
}, z.core.$strip>;MarkerSchema
constantA named point on the timeline (file version 4+): the editor shows it on the ruler.
const MarkerSchema: z.ZodMiniObject<{
id: z.ZodMiniString<string>;
time: z.ZodMiniInt;
label: z.ZodMiniOptional<z.ZodMiniString<string>>;
}, z.core.$strip>;NO_CROP
constantconst NO_CROP: Readonly<Crop>;PROJECT_VERSION
constantThe project file format. Plain JSON, validated on load, versioned with migrations (see migrate.ts). Everything an edit changes lives here — media files are never modified.
Conventions:
- Times are integer flicks (see
time.ts). - Positions are fractions of the canvas (0…1, centre = 0.5) and scale is relative to the size that fits the item inside the canvas, so changing the aspect ratio keeps layouts sensible.
const PROJECT_VERSION = 6;ProjectSchema
constantconst ProjectSchema: z.ZodMiniObject<…>;RegionItemSchema
constantA blurred or pixelated area (file version 3+): hides what is under it (faces, number plates) for its time on a picture layer. The box is width × height (fractions of the canvas width and height) at transform.scale 1, centred at transform.x / y and turned by transform.rotation; transform.opacity fades the effect.
const RegionItemSchema: z.ZodMiniObject<…>;SHAPE_CATEGORIES
constantPicker groups, in order.
const SHAPE_CATEGORIES: readonly ["basic", "polygons", "stars", "flowers", "organic", "symbols"];SHAPE_PRESETS
constantEvery mask shape, in picker order (117).
const SHAPE_PRESETS: readonly ShapePreset[];ShapeFamily
constantShape families (the shader's shape.x).
const ShapeFamily: {
readonly none: 0;
readonly polygon: 1;
readonly star: 2;
readonly roundedBox: 3;
readonly ellipse: 4;
readonly heart: 5;
readonly cross: 6;
readonly ring: 7;
readonly flower: 8;
readonly squircle: 9;
readonly crescent: 10;
readonly arrow: 11;
readonly cog: 12;
readonly blob: 13;
readonly bubble: 14;
readonly cloud: 15;
};ShapeMaskSchema
constantA shape mask (file version 4+, optional): the picture shows only inside the shape (or only outside it, invert). The shape fits the picture's box (effects/shapes.ts).
const ShapeMaskSchema: z.ZodMiniObject<{
shape: z.ZodMiniString<string>;
feather: z.ZodMiniNumber<number>;
invert: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
}, z.core.$strip>;STICKER_EMOJI
constantCommon emoji for the sticker panel (stored as sticker.emoji). Drawn with the system's font.
const STICKER_EMOJI: readonly string[];StickerItemSchema
constantconst StickerItemSchema: z.ZodMiniObject<…>;TEMPLATE_CATEGORIES
constantTemplate groups, in picker order.
const TEMPLATE_CATEGORIES: readonly ["intro", "lower-third", "quote", "social", "sale", "list", "event", "vlog", "outro"];TEMPLATE_PRESETS
constantEvery template: each layout in each theme (27 × 6 = 162).
const TEMPLATE_PRESETS: readonly TemplatePreset[];TEMPLATE_THEMES
constantThe looks every layout comes in.
const TEMPLATE_THEMES: readonly Theme[];TextItemSchema
constantconst TextItemSchema: z.ZodMiniObject<…>;TextStyleSchema
constantText look. Units (engine/text.ts): font size = size × canvas height × transform.scale; letterSpacing in em; lineHeight, outline.width, background.padding and background.radius × font size; shadow blur / x / y in px at a 1080-px-tall canvas.
const TextStyleSchema: z.ZodMiniObject<{
fontFamily: z.ZodMiniString<string>;
fontWeight: z.ZodMiniInt;
italic: z.ZodMiniBoolean<boolean>;
size: z.ZodMiniNumber<number>;
color: z.ZodMiniString<string>;
align: z.ZodMiniEnum<{
left: "left";
right: "right";
center: "center";
}>;
lineHeight: z.ZodMiniNumber<number>;
letterSpacing: z.ZodMiniNumber<number>;
outline: z.ZodMiniNullable<z.ZodMiniObject<{
color: z.ZodMiniString<string>;
width: z.ZodMiniNumber<number>;
}, z.core.$strip>>;
shadow: z.ZodMiniNullable<z.ZodMiniObject<{
color: z.ZodMiniString<string>;
blur: z.ZodMiniNumber<number>;
x: z.ZodMiniNumber<number>;
y: z.ZodMiniNumber<number>;
}, z.core.$strip>>;
background: z.ZodMiniNullable<z.ZodMiniObject<{
color: z.ZodMiniString<string>;
padding: z.ZodMiniNumber<number>;
radius: z.ZodMiniNumber<number>;
}, z.core.$strip>>;
}, z.core.$strip>;TrackSchema
constantconst TrackSchema: z.ZodMiniObject<…>;TRANSCRIBE_SAMPLE_RATE
constantSample rate the editor gives transcribers.
const TRANSCRIBE_SAMPLE_RATE = 16000;TransformSchema
constantconst TransformSchema: z.ZodMiniObject<{
x: z.ZodMiniNumber<number>;
y: z.ZodMiniNumber<number>;
scale: z.ZodMiniNumber<number>;
rotation: z.ZodMiniNumber<number>;
opacity: z.ZodMiniNumber<number>;
flipX: z.ZodMiniBoolean<boolean>;
flipY: z.ZodMiniBoolean<boolean>;
}, z.core.$strip>;TRANSITION_CATEGORIES
constantTransition groups with their labels, in display order.
const TRANSITION_CATEGORIES: readonly {
readonly id: TransitionCategory;
readonly label: string;
}[];TRANSITION_PRESETS
constantTransitions between main-track clips, in display order (grouped by category). Each plays over a window centred on the cut (half before, half after).
const TRANSITION_PRESETS: readonly TransitionPreset[];TransitionSchema
constantconst TransitionSchema: z.ZodMiniObject<{
type: z.ZodMiniString<string>;
duration: z.ZodMiniInt;
direction: z.ZodMiniOptional<z.ZodMiniEnum<{
left: "left";
right: "right";
up: "up";
down: "down";
}>>;
ease: z.ZodMiniOptional<z.ZodMiniEnum<{
linear: "linear";
smooth: "smooth";
"ease-in": "ease-in";
"ease-out": "ease-out";
snappy: "snappy";
expo: "expo";
back: "back";
anticipate: "anticipate";
bounce: "bounce";
elastic: "elastic";
ball: "ball";
"slow-mo": "slow-mo";
steps: "steps";
}>>;
}, z.core.$strip>;UNSURE_BELOW
constantCaptions whose words average a confidence under this are marked to check.
const UNSURE_BELOW = 0.6;VERSION
constantconst VERSION = "0.0.0";VideoItemSchema
constantconst VideoItemSchema: z.ZodMiniObject<…>;Types
Adjust
typetype Adjust = z.infer<typeof AdjustSchema>;AdjustKey
typeOne adjustment slider. Every value is −1…1 and 0 means unchanged.
interface AdjustKey {
readonly key: keyof Adjust;
readonly label: string;
}AnimationClip
typeAn entrance or exit animation (animation.in / animation.out).
type AnimationClip = z.infer<typeof AnimationClipSchema>;AnimationLoop
typeA repeating animation (animation.loop).
type AnimationLoop = z.infer<typeof AnimationLoopSchema>;AnimationPreset
typeAn animation the user can pick, for one slot.
interface AnimationPreset {
/** Unique across all slots; stored in `item.animation[slot].type`. */
readonly id: string;
readonly label: string;
readonly slot: AnimationSlot;
/** Group for the UI (see {@link ANIMATION_CATEGORIES}). */
readonly category: string;
/** Only for text items (typewriter, word by word); elsewhere they play as a fade. */
readonly textOnly?: boolean;
/** Suggested length in seconds (entrances and exits). */
readonly defaultDuration?: number;
}AnimationSlot
typeWhich part of an item's life an animation plays in.
type AnimationSlot = 'in' | 'out' | 'loop';ApplyOptions
typeinterface ApplyOptions {
/**
* Consecutive edits with the same key within `coalesceMs` merge into one undo step
* (a slider dragged for two seconds = one undo).
*/
coalesceKey?: string;
coalesceMs?: number;
}ArrangeTo
typeWhere arrangeItem moves an element in the stack.
type ArrangeTo = 'forward' | 'backward' | 'front' | 'back';Asset
typeAn imported media file.
type Asset = z.infer<typeof AssetSchema>;Sound-only export formats: AAC in .m4a, Opus in .ogg, or uncompressed 16-bit .wav.
type AudioExportFormat = 'm4a' | 'ogg' | 'wav';What to export when exporting only the sound (the same mix as a video export).
interface AudioExportOptions {
format: AudioExportFormat;
/** Sets the bitrate of AAC / Opus (96 / 128 / 192 kb/s); WAV is always lossless. */
quality: ExportOptions['quality'];
/** Export only this part of the timeline; omitted = the whole video. */
range?: ExportRange;
}A finished sound-only export (48 kHz stereo).
interface AudioExportResult {
/** The sound file (OPFS-backed like video exports, or in memory as a fallback). */
blob: Blob;
mimeType: string;
extension: AudioExportFormat;
/** `aac`, `opus` or `pcm-s16`. */
codec: string;
sampleRate: number;
channels: number;
durationSeconds: number;
storage: 'opfs' | 'memory';
/** Wall time of the export, seconds. */
elapsedSeconds: number;
warnings: string[];
}AudioFx
typetype AudioFx = z.infer<typeof AudioFxSchema>;AudioItem
typetype AudioItem = z.infer<typeof AudioItemSchema>;Background
typetype Background = z.infer<typeof BackgroundSchema>;What BackgroundRemover.remove gets.
interface BackgroundRemovalRequest {
/** The picture (any format the browser decodes). */
image: Blob;
signal: AbortSignal;
onProgress?: (progress: {
stage: 'download' | 'work';
fraction: number;
}) => void;
}Makes a picture's background transparent. Implement it to use your own service.
interface BackgroundRemover {
/** The picture with its background removed: a PNG with transparency, the same size. */
remove(request: BackgroundRemovalRequest): Promise<Blob>;
check?(): Promise<BackgroundRemoverCheck>;
/** Frees its model / worker (optional). */
dispose?(): void;
}Whether and how background removal can run here.
interface BackgroundRemoverCheck {
available: boolean;
/** True when it runs on the device (nothing is uploaded). */
onDevice: boolean;
/** One-time download in MB (first use only), if any. */
downloadMB?: number;
reason?: string;
}Bezier
typeA custom timing curve [x1, y1, x2, y2].
type Bezier = z.infer<typeof BezierSchema>;BlendMode
typeHow a layer mixes with what's under it.
type BlendMode = z.infer<typeof BlendModeSchema>;Capabilities
typeWhat the current browser and device can do. Produced by detectCapabilities.
interface Capabilities {
/** `navigator.gpu` exists and an adapter could be requested. */
webgpu: boolean;
/** A WebGL2 context can be created. */
webgl2: boolean;
/** `VideoDecoder`, `VideoEncoder`, `AudioDecoder` and `AudioEncoder` exist. */
webcodecs: {
video: boolean;
audio: boolean;
};
/** `OffscreenCanvas` exists and can be transferred to a worker. */
offscreenCanvas: boolean;
/** Origin Private File System is available. */
opfs: boolean;
/** File System Access API (`showOpenFilePicker`) is available — Chromium desktop only. */
fileSystemAccess: boolean;
/** Video codecs the device can decode at 1080p. */
decode: {
avc: boolean;
hevc: boolean;
vp9: boolean;
av1: boolean;
};
/** Codecs the device can encode. */
encode: {
avc1080: boolean;
avc4k: boolean;
vp9: boolean;
aac: boolean;
opus: boolean;
};
/** Approximate RAM in GB (`navigator.deviceMemory`), or `null` when the browser hides it. */
deviceMemoryGb: number | null;
/** Logical CPU cores. */
cores: number;
/** Phone or tablet. */
mobile: boolean;
/** GPU description, when the browser exposes it. */
gpu: string | null;
/** Suggested performance tier. */
tier: DeviceTier;
/** Everything needed to edit video is present. */
supported: boolean;
}CaptionInput
typeA caption to add: when it shows, its text, and (optionally) its words' times within it.
interface CaptionInput {
start: Time;
end: Time;
text: string;
words?: CaptionWord[];
/** The speech was hard to hear: marked to check. */
unsure?: boolean;
}CaptionLook
typeA caption row's look: preset and word highlight.
type CaptionLook = z.infer<typeof CaptionLookSchema>;CaptionLookPatch
typeA change to every caption's look at once.
interface CaptionLookPatch {
/** Apply a preset (text style, place and highlight). */
preset?: CaptionPreset;
highlight?: CaptionLook['highlight'];
highlightColor?: string;
style?: Partial<TextStyle>;
/** Where captions sit (centre, fractions of the canvas) and their size. */
x?: number;
y?: number;
scale?: number;
}CaptionPreset
typeCaption style presets (v0.2 A3): a text style, where captions sit, and how the word being said is highlighted. Our own designs; fonts are the editor's font presets (system fonts).
interface CaptionPreset {
id: string;
label: string;
style: TextStyle;
/** Vertical centre as a fraction of the canvas (0.82 ≈ lower third). */
y: number;
highlight: CaptionLook['highlight'];
highlightColor: string;
}CaptionWord
typeOne spoken word of a caption (times relative to the caption's start).
type CaptionWord = z.infer<typeof CaptionWordSchema>;ChromaKey
typeGreen-screen settings of a picture.
type ChromaKey = z.infer<typeof ChromaKeySchema>;CopiedItem
typeA copied item and whether it was a clip of the main video (see pasteItems).
interface CopiedItem {
item: Item;
fromMain: boolean;
}Options for createProject.
interface CreateProjectOptions {
name?: string;
/** Canvas size in pixels. Default 1080 × 1920 (9:16, phone video). */
width?: number;
height?: number;
frameRate?: FrameRate;
ids?: IdFactory;
/** ISO timestamp; defaults to now. */
now?: string;
}Crop
typetype Crop = z.infer<typeof CropSchema>;Cutout
typeA picture with its background removed.
type Cutout = z.infer<typeof CutoutSchema>;DeviceTier
typePerformance tier of the current device. Sets preview resolution, export limits and cache sizes.
type DeviceTier = 'high' | 'mid' | 'low';Direction
typeWhich way a transition moves.
type Direction = z.infer<typeof DirectionSchema>;Ease
typeA transition's timing curve.
type Ease = z.infer<typeof EaseSchema>;EditAction
typeOne edit a model asked for (validated by EditActionSchema).
type EditAction = z.infer<typeof EditActionSchema>;EditContext
typeContext passed to every edit recipe.
interface EditContext {
ids: IdFactory;
}EditErrorCode
typeWhy an edit was refused.
type EditErrorCode = 'not-found' | 'locked' | 'invalid';EditingAssistant
typeTurns an instruction into edit actions — implement it with your own model endpoint (keys stay on your server). @video-ultra/ai has createChatAssistant for OpenAI-compatible endpoints.
interface EditingAssistant {
edit(request: EditingRequest): Promise<EditingResponse>;
}EditingRequest
typeWhat an EditingAssistant gets.
interface EditingRequest {
/** What the person asked, in their words. */
instruction: string;
/** {@link describeProject} of the project now. */
project: ProjectDescription;
/** Ids of the selected items (the person may say "this clip"). */
selection: string[];
/** Playhead, seconds ("here"). */
playhead: number;
/** Earlier turns of this conversation (oldest first). */
history: {
instruction: string;
reply: string;
}[];
signal: AbortSignal;
}EditingResponse
typeWhat an EditingAssistant answers.
interface EditingResponse {
/** A short sentence for the person (what was done, or a question back). */
reply: string;
/** Edits to apply (may be empty: a question or "can't do that"). */
actions: unknown[];
}Editor
typeThe editor's state container: project + undo/redo + operation log.
interface Editor {
readonly store: StoreApi<EditorState>;
getProject(): Project;
/**
* Runs an edit. `recipe` mutates a draft (use the functions from `ops.ts`). If it throws, the
* project is unchanged and the error is re-thrown. Returns the recipe's return value.
*/
apply<R>(label: string, recipe: (draft: Project, ctx: EditContext) => R, options?: ApplyOptions): R;
undo(): boolean;
redo(): boolean;
/** The history as a list, for showing it. */
history(): HistoryView;
/**
* Undoes or redoes until `position` steps are applied (see {@link HistoryView}). Each step is
* logged as its own undo / redo. Returns false if `position` is out of range.
*/
goTo(position: number): boolean;
/** Replaces the project (e.g. opening another one); clears history. */
load(project: Project): void;
/** Called after every commit, undo and redo — persist the entry for autosave/crash recovery. */
onCommit(listener: (entry: LogEntry, project: Project) => void): () => void;
}EditorOptions
typeinterface EditorOptions {
ids?: IdFactory;
/** Max undo steps kept in memory. Default 300. */
historyLimit?: number;
/** Clock for coalescing (tests). */
now?: () => number;
}EditorState
typeState of the editor store. Subscribe with selectors to re-render only what changed.
interface EditorState {
project: Project;
canUndo: boolean;
canRedo: boolean;
/** Label of the edit that undo would revert. */
undoLabel: string | null;
redoLabel: string | null;
}ExportHeight
typeOutput resolutions offered, named by the output's shorter side in pixels.
type ExportHeight = 480 | 720 | 1080 | 1440 | 2160;ExportLimits
typeWhat this device can export. From exportLimits.
interface ExportLimits {
/** Heights (shorter side) both allowed for the tier and accepted by an encoder, per format. */
mp4: ExportHeight[];
webm: ExportHeight[];
/** AAC (MP4 sound) needs a downloaded encoder here (about 280 KB, loaded only when exporting). */
aacFallback: boolean;
/** Opus (WebM sound) can be encoded. Without it a WebM export has no sound. */
opus: boolean;
/** Heights HEVC (H.265, in MP4) and AV1 (MP4 / WebM) can be encoded at, if any (v0.4). */
hevc: ExportHeight[];
av1: ExportHeight[];
}ExportOptions
typeWhat to export.
interface ExportOptions {
/** `mp4` = H.264 + AAC (plays everywhere); `webm` = VP9 (or VP8) + Opus. */
format: 'mp4' | 'webm';
/**
* The output's **shorter side** in pixels (720 = 720 × 1280 for a 9:16 project, 1280 × 720 for
* 16:9). The longer side follows the project's aspect ratio, rounded to even pixels.
*/
height: ExportHeight;
fps: 24 | 30 | 60;
quality: 'low' | 'medium' | 'high';
/**
* The video codec (v0.4): `auto` (default — H.264 for MP4, VP9 / VP8 for WebM), or a newer one
* for a smaller file where this device can encode it ({@link ExportLimits}): `hevc` (H.265,
* MP4) or `av1` (MP4 or WebM); `h264` / `vp9` ask for the default one by name.
*/
videoCodec?: ExportVideoCodec;
/**
* Export only this part of the timeline (flicks, `start` inclusive, `end` exclusive). Omitted:
* the whole video. Clamped to the video's length; transitions, animations and sound at the
* edges are exactly what plays at those times.
*/
range?: ExportRange;
}ExportPreset
typeA ready-made export setting for a common destination.
interface ExportPreset {
/** Stable id: `vertical`, `widescreen` or `square`. */
id: 'vertical' | 'widescreen' | 'square';
/** The frame shape it is made for (`9:16`, `16:9`, `1:1`) as a canvas size. */
aspect: {
width: number;
height: number;
};
/** Shorter side in pixels. */
height: ExportHeight;
/** Frame rate; `null` keeps the project's own (24, 30 or 60). */
fps: ExportOptions['fps'] | null;
format: ExportOptions['format'];
quality: ExportOptions['quality'];
}ExportProgress
typeExport progress, reported about 4 times a second.
interface ExportProgress {
/** 0…1 */
fraction: number;
framesDone: number;
framesTotal: number;
/** Estimated seconds left, once a few frames have been measured. */
etaSeconds: number | null;
}ExportRange
typeA part of the timeline, in flicks: from start up to (not including) end.
interface ExportRange {
start: Time;
end: Time;
}ExportResult
typeA finished export.
interface ExportResult {
/**
* The video file. With `storage: 'opfs'` it is backed by a file in the origin-private file
* system and stays readable until the next export starts (which deletes it).
*/
blob: Blob;
mimeType: string;
extension: 'mp4' | 'webm';
width: number;
height: number;
durationSeconds: number;
/** Where the file was written while exporting: on disk (OPFS) or, as a fallback, in memory. */
storage: 'opfs' | 'memory';
/** Frames written. */
frames: number;
/** Codecs used, e.g. `avc` + `aac`; audio null when the project has no sound. */
videoCodec: string;
audioCodec: string | null;
/** Wall time of the export, seconds. */
elapsedSeconds: number;
/**
* The file is see-through where the project's background is transparent (WebM with VP9 / VP8
* alpha). False for every other export, including MP4 of a transparent project (black there).
*/
transparent: boolean;
/** Things the user should know (e.g. no Opus encoder → video without sound). */
warnings: string[];
}ExportVideoCodec
typeVideo codecs an export can ask for (see ExportOptions.videoCodec).
type ExportVideoCodec = 'auto' | 'h264' | 'hevc' | 'av1' | 'vp9';Filter
typetype Filter = z.infer<typeof FilterSchema>;FilterCategory
typeFilter groups, in display order.
type FilterCategory = 'natural' | 'vivid' | 'warm' | 'cool' | 'film' | 'vintage' | 'cinematic' | 'moody' | 'pastel' | 'bw' | 'retro' | 'food' | 'portrait' | 'landscape' | 'night';FilterPreset
typeA filter the user can pick. id goes into item.filter.id.
interface FilterPreset {
readonly id: string;
readonly label: string;
/** Group for the UI (see {@link FILTER_CATEGORIES}). */
readonly category: FilterCategory;
}FontPreset
typeA text style preset: a font stack the device already has (nothing is downloaded).
interface FontPreset {
readonly id: string;
readonly label: string;
/** CSS font-family list for `TextStyle.fontFamily`. */
readonly family: string;
/** CSS font weight for `TextStyle.fontWeight`. */
readonly weight: number;
}FrameImage
typeOne frame saved as a picture, drawn by the same compositor as the export.
interface FrameImage {
blob: Blob;
mimeType: string;
extension: 'png' | 'jpg';
width: number;
height: number;
}FrameImageFormat
typeStill-image formats for saving a frame.
type FrameImageFormat = 'png' | 'jpeg';Options for saving one frame of the video as a picture.
interface FrameImageOptions {
format: FrameImageFormat;
/** JPEG quality 0…1 (default 0.92). Ignored for PNG. */
quality?: number;
/**
* The picture's shorter side in pixels; omitted = the project's own size (its canvas, e.g.
* 1080 × 1920). The longer side follows the project's aspect ratio.
*/
height?: number;
}FrameRate
typeA frame rate as a rational number, e.g. 29.97 fps = { num: 30000, den: 1001 }.
interface FrameRate {
num: number;
den: number;
}FreezeItem
typetype FreezeItem = z.infer<typeof FreezeItemSchema>;GroupedCaption
typeA caption made from words: its time on the timeline, text, and word times within it.
interface GroupedCaption {
start: Time;
end: Time;
text: string;
words: CaptionWord[];
/** Its words were heard with little confidence: worth checking. */
unsure?: boolean;
}GroupOptions
typeOptions of groupCaptions.
interface GroupOptions {
/**
* Most characters on screen at once (one line ≈ 32; a Chinese / Japanese character counts
* two). Default 32.
*/
maxChars?: number;
/** Longest a caption stays (s). Default 3.5. */
maxSeconds?: number;
/** A silence this long (s) starts a new caption. Default 0.6. */
pauseSeconds?: number;
}HistoryView
typeThe undo history as a list (the History panel).
interface HistoryView {
/** Step labels, oldest first: the undoable steps, then the redoable ones. */
labels: readonly string[];
/**
* How many steps are applied: 0 = the project as opened ("Original"), `labels.length` = latest.
* Steps after it are the ones redo would bring back.
*/
position: number;
}IdFactory
typeMakes unique ids. Injectable so tests are deterministic.
type IdFactory = () => string;ImageItem
typetype ImageItem = z.infer<typeof ImageItemSchema>;Item
typeAnything that sits on a track.
type Item = z.infer<typeof ItemSchema>;ItemAnimation
typeA lane item's animations.
type ItemAnimation = z.infer<typeof ItemAnimationSchema>;ItemKind
typetype ItemKind = Item['kind'];ItemPatch
typeFields that updateItem may change. Timing and media references have their own operations.
interface ItemPatch {
name?: string;
transform?: Transform;
crop?: Crop;
fit?: 'fit' | 'fill';
filter?: Filter | null;
adjust?: Adjust;
volume?: number;
muted?: boolean;
fadeIn?: Time;
fadeOut?: Time;
/** Lower under voice, 0…1 of the volume taken away while someone speaks; 0 = off. */
duck?: number;
/** Sound effects (EQ, compressor, pitch); `null` removes them. */
audioFx?: AudioFx | null;
text?: string;
style?: TextStyle;
/**
* Texts: wrap width as a fraction of the canvas width at scale 1 (clamped to 0.05…1); `null`
* removes it (lines break only where the text does).
*/
maxWidth?: number | null;
emoji?: string | null;
/** Green screen; `null` turns it off. */
key?: ChromaKey | null;
/** LUT look (the asset must be a `lut`); `null` removes it. */
lut?: LutRef | null;
/** Lane items; `'normal'` (or `null`) removes the field. */
blend?: BlendMode | null;
/** Pictures: shape mask (the shape must be one of `SHAPE_PRESETS`); `null` removes it. */
mask?: ShapeMask | null;
/** Photos and image stickers: background removed (an image asset); `null` restores it. */
cutout?: Cutout | null;
/** Blurred areas. */
effect?: RegionItem['effect'];
shape?: RegionItem['shape'];
amount?: number;
width?: number;
height?: number;
}Keyframe
typeOne keyframe: a time (flicks from the item's start), a value, the curve to the next.
type Keyframe = z.infer<typeof KeyframeSchema>;KeyframeProp
typeA property that takes keyframes.
type KeyframeProp = (typeof KEYFRAME_PROPS)[number];Keyframes
typeAn item's keyframes, per transform property (time order).
type Keyframes = z.infer<typeof KeyframesSchema>;LogEntry
typeOne committed edit, as stored in the operation log.
interface LogEntry {
/** Increases by one per commit, across undo/redo too. */
seq: number;
/** What the user did, e.g. "Split clip". Shown in history UI. */
label: string;
/** Applying these to the previous project gives the next one. */
patches: Patch[];
/** Applying these undoes the entry. */
inverse: Patch[];
/** `edit`, or `undo` / `redo` of an earlier entry. */
kind: 'edit' | 'undo' | 'redo';
}LutRef
typeA picture's LUT look.
type LutRef = z.infer<typeof LutRefSchema>;Marker
typeA named point on the timeline.
type Marker = z.infer<typeof MarkerSchema>;ParseResult
typeResult of parseProject.
type ParseResult = {
ok: true;
project: Project; /** Things that were fixed while loading. */
warnings: string[];
} | {
ok: false;
error: string;
};Project
typeA whole project: settings, media and tracks.
type Project = z.infer<typeof ProjectSchema>;The compact view of a project a model reads.
interface ProjectDescription {
/** The video's name. */
name: string;
canvas: {
width: number;
height: number;
};
duration: number;
tracks: {
kind: string;
items: Record<string, string | number | boolean | null>[];
}[];
markers: {
time: number;
label?: string;
}[];
/** The media library: every imported video, photo and sound, on the timeline or not. */
media: {
id: string;
name: string;
kind: string;
duration?: number;
onTimeline: boolean;
}[];
catalog: {
filters: string[];
transitions: string[];
animationsIn: string[];
animationsOut: string[];
soundPresets: string[];
};
}RegionItem
typeA blurred / pixelated area on a picture layer.
type RegionItem = z.infer<typeof RegionItemSchema>;RenderBackend
typeWhich GPU API a renderer uses.
type RenderBackend = 'webgpu' | 'webgl2';ShapeMask
typeA picture's shape mask.
type ShapeMask = z.infer<typeof ShapeMaskSchema>;ShapePreset
typeOne mask shape.
interface ShapePreset {
id: string;
/** Picker group. */
category: 'basic' | 'polygons' | 'stars' | 'flowers' | 'organic' | 'symbols';
family: number;
/** Family parameters (see each family in {@link shapeDistance}). */
a: number;
b: number;
c: number;
/** Turned by this many degrees (clockwise). */
rotation: number;
/** Stretches to the picture's box instead of keeping its proportions. */
stretch: boolean;
}SpeechGenerator
typeTurns text into speech. Implement it to use your own service.
interface SpeechGenerator {
/** The voices to offer (first = default). */
voices(): SpeechVoice[] | Promise<SpeechVoice[]>;
/** The speech as an audio file the browser can decode (MP3, WAV, Opus…). */
speak(request: SpeechRequest): Promise<Blob>;
/**
* `true`: the service speaks at {@link SpeechRequest.speed} itself. Otherwise (the default) the
* editor asks for normal speed and plays the added clip at the chosen speed with the voice's
* pitch kept ("Keep the voice natural"), so the speed works with any service.
*/
appliesSpeed?: boolean;
}SpeechPosition
typeWhere speech is at local time: the word being said (−1 before the first) and 0…1 through it.
interface SpeechPosition {
/** Index of the current word; words before it are done. −1 before any word starts. */
word: number;
/** 0…1 through the current word (1 between words). */
progress: number;
/** Characters of the text done, counting the current word partly (for letter-by-letter). */
chars: number;
/** All characters (letters of the words, spaces excluded). */
totalChars: number;
}SpeechRequest
typeWhat SpeechGenerator.speak gets.
interface SpeechRequest {
text: string;
voice: string;
/**
* 0.5…2, 1 = normal. Always 1 unless the generator says it applies the speed itself
* ({@link SpeechGenerator.appliesSpeed}).
*/
speed: number;
signal: AbortSignal;
}SpeechVoice
typeA voice to pick.
interface SpeechVoice {
id: string;
/** Shown to people. */
name: string;
/** BCP-47 tag when known, e.g. `en`, `hi`. */
language?: string;
}StickerItem
typetype StickerItem = z.infer<typeof StickerItemSchema>;SubtitleCue
typeOne subtitle: when it shows and its text (lines joined with \n).
interface SubtitleCue {
start: Time;
end: Time;
text: string;
}TemplateCategory
typetype TemplateCategory = (typeof TEMPLATE_CATEGORIES)[number];TemplateElement
typeOne element of a template. Times in seconds from the template's start.
interface TemplateElement {
kind: 'text' | 'emoji';
/** Text with `{variable}`s, or the emoji. */
content: string;
/** Centre, fractions of the canvas. */
x: number;
y: number;
/** Emoji: size as a fraction of the canvas's shorter side. Text: ignored (style.size). */
scale?: number;
rotation?: number;
style?: Partial<TextStyle>;
/** Text wrap width, fraction of the canvas width. */
maxWidth?: number;
start: number;
duration: number;
in?: string;
out?: string;
loop?: string;
}TemplatePreset
typeOne template.
interface TemplatePreset {
id: string;
name: string;
category: TemplateCategory;
/** Look family (`TEMPLATE_THEMES`). */
theme: string;
/** Seconds. */
duration: number;
elements: readonly TemplateElement[];
variables: readonly TemplateVariable[];
}TemplateTheme
typeA template theme: the colours and fonts a template is drawn with.
interface Theme {
id: string;
name: string;
title: string;
body: string;
ink: string;
accent: string;
boxInk: string;
card: string;
cardInk: string;
/** Title look extras. */
titleShadow: TextStyle['shadow'];
titleOutline: TextStyle['outline'];
letterSpacing: number;
in: string;
out: string;
}TemplateVariable
typeA variable a template asks for.
interface TemplateVariable {
key: string;
/** What to ask ("Your name"). */
label: string;
/** Example value, filled in at first. */
example: string;
}TextItem
typetype TextItem = z.infer<typeof TextItemSchema>;TextStyle
typetype TextStyle = z.infer<typeof TextStyleSchema>;Time
typeTimeline time is an integer number of flicks (1/705,600,000 s). Every common frame rate (23.976, 24, 25, 29.97, 30, 50, 59.94, 60, 120) and audio sample rate (44.1 / 48 / 96 kHz) divides a second into a whole number of flicks, so frame and sample boundaries are exact integers: splitting, trimming and summing durations never drift the way float seconds do. The largest safe value is ~147 days.
type Time = number;Track
typetype Track = z.infer<typeof TrackSchema>;TrackKind
typetype TrackKind = Track['kind'];Progress of a transcription, for a progress bar.
interface TranscribeProgress {
/** `download`: fetching the speech model (first use only); `transcribe`: listening. */
stage: 'download' | 'transcribe';
/** 0…1. */
fraction: number;
/** Bytes downloaded so far / in total (download stage). */
loaded?: number;
total?: number;
}Transcriber
typeTurns speech into timed words. Implement this to use your own speech service.
interface Transcriber {
/**
* Languages it hears (ISO 639-1), plus `'auto'` if it can detect the language. The Captions
* panel offers only these, and shows no choice when there's one. Default: the panel's own
* list and Detect.
*/
readonly languages?: readonly string[];
/** It uses `TranscribeRequest.vocabulary`: the Captions panel offers a "Names to spell right" field. */
readonly takesVocabulary?: boolean;
transcribe(request: TranscribeRequest): Promise<TranscribeResult>;
/** Optional: whether and how `language` can be transcribed here, before starting. */
check?(language: string): Promise<TranscriberCheck>;
/** Frees its model / worker (optional). */
dispose?(): void;
}TranscriberCheck
typeWhat transcribing a language would take on this device (shown before starting).
interface TranscriberCheck {
/** False when it can't run here; `reason` says why. */
available: boolean;
/** True when it runs on the device (nothing is uploaded). */
onDevice: boolean;
/** One-time download in MB (first use only), if any. */
downloadMB?: number;
/** Roughly how many seconds of speech it hears per second (for "about N min"). */
speed?: number;
reason?: string;
/**
* True when it should work but may need more memory than this device can give (a large model
* on a phone): the editor says so before the user starts.
*/
memoryRisk?: boolean;
}What the editor hands a transcriber.
interface TranscribeRequest {
/**
* The sound, as 16 kHz mono PCM in order, in pieces of at most 30 s (so memory stays flat on
* long videos). Pieces follow each other with no gap.
*/
audio: AsyncIterable<Float32Array>;
/** Length of the whole sound in seconds (for progress). */
duration: number;
/**
* Spoken language as an ISO 639-1 code (`'en'`, …), `'hi-Latn'` for Hinglish (Hindi written in
* Latin letters), or `'auto'` to detect it (one of `languages`).
*/
language: string;
/**
* Names and words that may be said (people, brands, places), so they're spelled right — for
* transcribers with `takesVocabulary`. Optional.
*/
vocabulary?: readonly string[];
/** Cancels the transcription; the promise then rejects with an `AbortError`. */
signal: AbortSignal;
onProgress?: (progress: TranscribeProgress) => void;
}TranscribeResult
typeThe result: every word with its time, and the language heard.
interface TranscribeResult {
words: TranscriptWord[];
language: string;
}TranscriptWord
typeOne recognised word and when it is spoken (seconds from the start of the audio).
interface TranscriptWord {
text: string;
start: number;
end: number;
/**
* How sure the recogniser is of this word, 0…1 (optional). Captions whose words average under
* 0.6 are marked to check.
*/
confidence?: number;
}Transform
typetype Transform = z.infer<typeof TransformSchema>;Transition
typetype Transition = z.infer<typeof TransitionSchema>;Transition groups, in display order.
type TransitionCategory = 'basic' | 'slide' | 'wipe' | 'zoom' | 'blur' | 'light' | 'glitch' | 'shape' | 'distort' | '3d';TransitionPreset
typeA transition the user can pick. id goes into item.transitionIn.type.
interface TransitionPreset {
readonly id: string;
readonly label: string;
readonly category: TransitionCategory;
/** Directions it can move in (`transitionIn.direction`); the first is the default. */
readonly directions?: readonly Direction[];
/** Suggested length in seconds (default 0.5). */
readonly defaultDuration?: number;
/** The curve it uses when `transitionIn.ease` is missing. */
readonly ease: Ease;
}VideoItem
typetype VideoItem = z.infer<typeof VideoItemSchema>;