Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
TL7l, TL7m: a composition's footage cut out. raea's <Video> takes a matte (sdk/video media.tsx, VideoMatte exported from raea/video): a folder of PNG mattes in the media folder (m00001.png on), the file's rate, one each every frames and how many; it wears the one its source time is on (data-source-time, so trims, playbackRate, speed curves and loops follow) as its mask-image, sized and placed as its objectFit and objectPosition place the picture, the last past the end, and refuses it with framing or punchIn (the engine places those). Blitz paints raster mask-images as it paints backgrounds, and raea's render loads each frame's: a 3 s face clip's Vision mattes worn this way kept on every frame what that frame's matte keeps (overlap 0.92 at least, 0.972 on average; the uncut composition 0.53). sdk/timeline copies.ts: a media row's cutout (the matte prop's numbers, data-matte, data-brush-at, data-brush-strokes) is its clip's matte props as a film's (matte, matted, and matteFps, matteEvery, matteCount), and a set of those is the host's new cutout edit (raea-feed 2c59ec6: the host mattes the whole of what the <Video> plays into its media folder's matte/ and writes the prop; Stabilise and Retouch are refused while it is on). Conformance: 4 new Video matte tests in cutout.test.tsx. The manual's video, raea, index and editor pages regenerated (pbr.md's drift left out)
shinyobjectzc4550ad6ba46
diff --git a/docs/manual/reference/sdk/editor.md b/docs/manual/reference/sdk/editor.mdindex 69c50e2b..6e991fcd 100644--- a/docs/manual/reference/sdk/editor.md+++ b/docs/manual/reference/sdk/editor.md@@ -1034,6 +1034,7 @@ the lane it sits on (nested ones below their parent, overlapping ones apart), an| `heard` | `{ of: string; denoise?: boolean; voice?: string }` | what it plays is a copy of `of` with its noise reduced or its voice changed (an <Audio>'s) || `steady` | `{ of: string; level: string }` | what it plays is a copy of `of` held steady at `level` (a <Video>'s) || `retouch` | `{ of: string; smooth?: number; brighten?: number; slim?: number; eyes?: number }` | what it plays is a copy of `of` with its faces retouched, each amount 0 to 1 (a <Video>'s): `of` is its file, or its steadied copy when it is held steady too (the retouch over the steadying) |+| `cutout` | `CutoutMatte & { kind: string; at?: number; strokes?: string }` | it wears a cutout's mattes (a <Video>'s): the folder in the media folder, the file's rate, one each `every` frames, how many; what they are of (person, subject or brushed) and, brushed, the second brushed at and the strokes' JSON |### `Showing`diff --git a/docs/manual/reference/sdk/index.md b/docs/manual/reference/sdk/index.mdindex 4e62a090..d62ea4f3 100644--- a/docs/manual/reference/sdk/index.md+++ b/docs/manual/reference/sdk/index.md@@ -55,7 +55,7 @@ Footage, pictures, sound, words and colour, and the timeline they are edited on.| Import | What it's for | Exports || --- | --- | --- |-| [`raea/video`](video.md) | Footage and time-shifted sequences: Video, Sequence, Series, Loop and Freeze. | 5 components, 7 types |+| [`raea/video`](video.md) | Footage and time-shifted sequences: Video, Sequence, Series, Loop and Freeze. | 5 components, 8 types || [`raea/audio`](audio.md) | Sound: Audio, the master Mix, speech, sound in 3D space, and a song's energy map. | 6 components, 1 hook, 7 functions, 1 value, 25 types || [`raea/text`](text.md) | Text in the 3D world, fonts, and time anchored to the words said. | 3 components, 1 hook, 3 functions, 6 types || [`raea/image`](image.md) | Pictures on the page and in the world, and texture atlases packed from them. | 3 components, 1 class, 5 types |diff --git a/docs/manual/reference/sdk/raea.md b/docs/manual/reference/sdk/raea.mdindex 6f70a1dd..30778704 100644--- a/docs/manual/reference/sdk/raea.md+++ b/docs/manual/reference/sdk/raea.md@@ -283,6 +283,7 @@ A video clip in step with the frame; `data-source-time` is the source time (seco| --- | --- | --- || `framing` | `"face"` | ours: frame the take on the largest face || `punchIn` | `number` | ours: multiplies the framing's scale (1.15 is the usual) |+| `matte` | `VideoMatte` | ours: its cutout: the mattes made of its file, which it wears as its mask, so what is cut out shows what is under it |Also takes the props of [`MediaProps`](video.md#mediaprops).diff --git a/docs/manual/reference/sdk/video.md b/docs/manual/reference/sdk/video.mdindex d9e3e819..f93a708a 100644--- a/docs/manual/reference/sdk/video.md+++ b/docs/manual/reference/sdk/video.md@@ -34,7 +34,7 @@ function Cut() {import { Freeze, Loop, Sequence, Series } from "raea/video"```-`raea/video` exports 5 components, 7 types. Bevy's counterpart: `raea's own; Bevy has no video crate`. Source: [sdk/raea/src/video.ts](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/src/video.ts).+`raea/video` exports 5 components, 8 types. Bevy's counterpart: `raea's own; Bevy has no video crate`. Source: [sdk/raea/src/video.ts](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/src/video.ts).## Components@@ -93,6 +93,7 @@ A video clip in step with the frame; `data-source-time` is the source time (seco| --- | --- | --- || `framing` | `"face"` | ours: frame the take on the largest face || `punchIn` | `number` | ours: multiplies the framing's scale (1.15 is the usual) |+| `matte` | `VideoMatte` | ours: its cutout: the mattes made of its file, which it wears as its mask, so what is cut out shows what is under it |Also takes the props of [`MediaProps`](#mediaprops).@@ -151,6 +152,17 @@ The props of [`Sequence`](#sequence), tabled there.| `width` | `number` | the width its children see, px (the parent's by default) || `durationInFrames` | `number` | how many frames it shows its children (forever by default) |+### `VideoMatte`++A clip's mattes: PNGs whose alpha is what is kept, m00001.png on, in one folder of the media folder.++| Field | Type | What it is |+| --- | --- | --- |+| `src` (required) | `string` | the folder, as staticFile gives it: staticFile("matte/take-person") |+| `fps` (required) | `number` | the file's frame rate: m00001.png is its frame 0 |+| `every` | `number` | one matte each `every` frames of the file, held until the next (1, every frame, when left out) |+| `count` (required) | `number` | how many mattes there are: past the last, the last is worn |+### `VideoProps`The props of [`Video`](#video), tabled there.diff --git a/docs/timeline.feature b/docs/timeline.featureindex 7f45f35f..8d2df39e 100644--- a/docs/timeline.feature+++ b/docs/timeline.feature@@ -60,7 +60,7 @@ Feature: The timeline SDK (0.1.5): CapCut's timeline, on the composition, in thetemperature, tint, fade, vignette, grain. Audio: volume, fades, noise reduction, voice changer. Text: font,style, effects, bubbles, animation, and its words read aloud.Here 11-14: Basic (TL3h, TL5) with stabilise (TL7k, a film's footage and a composition's <Video>), auto cutout- of a person or the subject (TL7l, a film's footage, on a Mac) and a custom one brushed on the picture (TL7m), Retouch (TL7n: smooth, brighten, slim face and bigger eyes, a film's footage, a file from Media or a composition's <Video>, on a Mac), Mask, chroma key and Blend (TL7f) with the key's colour picked from+ of a person or the subject (TL7l, a film's footage or a composition's <Video>, on a Mac) and a custom one brushed on the picture (TL7m), Retouch (TL7n: smooth, brighten, slim face and bigger eyes, a film's footage, a file from Media or a composition's <Video>, on a Mac), Mask, chroma key and Blend (TL7f) with the key's colour picked fromthe picture (TL7h) and the mask's handles dragged there (TL7i), Animation (TL7d, TL7e), Speed (TL6), Audio'svolume and fades (TL8a) and its noise reduction and voice changer (TL8d, a film's sounds and a composition's<Audio>), Text's words, styles and captions (TL7c) and its words read aloud (TL7j), Adjust as effect clips@@ -213,7 +213,17 @@ Feature: The timeline SDK (0.1.5): CapCut's timeline, on the composition, in thebefore for up to 3 frames; overlaps read as CIAreaAverage means undone from sRGB, a 25% square read0.2502; on two subjects side by side a stroke on either kept only it, both kept both, an erase tookone out, a stroke on the sky said nothing is under it; a real clip 90 frames in 11.9 s, the cat- followed through all of them; the strokes kept in the clip's props as JSON, there to brush again),+ followed through all of them; the strokes kept in the clip's props as JSON, there to brush again; in a+ composition, the whole of what its <Video> plays (its file, or its retouched or steadied copy) matted+ into its media folder's matte/, and the <Video> wears them by raea's new Video matte prop (matte={{ src:+ staticFile(folder), fps, every, count }}: the matte its source time is on, as its mask-image, sized as+ its objectFit sizes the picture), saying what they are of (data-matte; brushed, data-brush-at and+ data-brush-strokes), off its props as they were; while it wears them, Stabilise and Retouch are refused,+ since what it plays would change under them. A composition's strokes are on its frame, which is the+ <Video>'s picture only when the <Video> fills it. A real 3 s face clip's person matted in 9.1 s, and+ raea's render of the edited composition keeps on each frame what that frame's matte keeps (overlap 0.92+ at least, 0.972 on average; its own matte over the one 15 frames away on 88 of 90 frames), where the+ uncut composition's overlap is 0.53),TL7n (footage retouched, CapCut's Retouch: four sliders, smooth, brighten, slim face and bigger eyes, setthen applied; the host reads each frame of the part the clip shows (`raea media still`, as wide as thepicture up to 1280 px), finds its faces and their landmarks with Vision's face landmarks (up to 4 a@@ -274,7 +284,9 @@ Feature: The timeline SDK (0.1.5): CapCut's timeline, on the composition, in theclips: span, place in the file, level (TL14b). An <Audio>'s sound from its copy with its noisereduced or its voice changed: its src the copy, and data-voice-of, data-denoise and data-voice (TL8d).A <Video>'s footage from its steadied copy: its src the copy, and data-steady-of and data-steady (TL7k);- from its retouched copy, over the steadied one when both: data-retouch-of and the amounts (TL7n)+ from its retouched copy, over the steadied one when both: data-retouch-of and the amounts (TL7n). A+ <Video> cut out: its matte prop and data-matte, brushed with data-brush-at and data-brush-strokes (TL7l,+ TL7m)plays TL10a for a film's own frames: cuts, moves, trims, speeds, freezes and reversed footage at once, theplayer's buffer on the ruler. TL10f: a timed 3D scene's frames are drawn ahead by the host a fewseconds at a time at draft quality and kept by range, each range under what it is drawn from (thediff --git a/sdk/raea/conformance/cutout.test.tsx b/sdk/raea/conformance/cutout.test.tsxindex 4594ad27..f1ba2401 100644--- a/sdk/raea/conformance/cutout.test.tsx+++ b/sdk/raea/conformance/cutout.test.tsx@@ -2,6 +2,7 @@// <Nudge> from sdk/video cutout.ts.import { describe, expect, test } from "bun:test";import { BLEND_KINDS, chromaError, chromaId, chromaMatrix, maskError, maskPlain, maskStyle, maskSvg } from "@raea/video/cutout";+import { Video } from "@raea/video/media";import { Nudge } from "@raea/video/nudge";import { renderFrame } from "../src/test";@@ -131,3 +132,41 @@ describe("<Nudge> draws them on the part it places", () => {expect(() => renderFrame(<Nudge mask={{ kind: "circle", round: 4 }}><div /></Nudge>, opts)).toThrow(/round is from 0 to 1/);});});++describe("a <Video> wears its cutout's mattes (TL7l in a composition)", () => {+ const seq = (html: string) => /mask-image:url\(([^)]*)\)/.exec(html)?.[1];+ const at = (frame: number, more: object = {}) =>+ renderFrame(<Video src="/media/clips/take.mp4" startFrom={30} matte={{ src: "/media/matte/take-person", fps: 30, count: 90 }} {...more} />, { ...opts, durationInFrames: 120, frame });++ test("the matte its source frame was made from, as its mask over the picture as it is placed", () => {+ // from its frame 30 on: the composition's frame 10 shows the file's frame 40+ expect(seq(at(10))).toBe("/media/matte/take-person/m00041.png");+ expect(at(10)).toContain("mask-size:cover");+ expect(at(10)).toContain("mask-position:50% 50%");+ expect(seq(at(0, { playbackRate: 2 }))).toBe("/media/matte/take-person/m00031.png");+ expect(seq(at(5, { playbackRate: 2 }))).toBe("/media/matte/take-person/m00041.png");+ // contained, or stretched to the box, the matte is too+ expect(at(10, { style: { objectFit: "contain" } })).toContain("mask-size:contain");+ expect(at(10, { style: { objectFit: "fill" } })).toContain("mask-size:100% 100%");+ });++ test("one matte each few frames is held until the next; past the last, the last", () => {+ const sparse = { matte: { src: "/media/matte/take-person/", fps: 30, every: 4, count: 23 } };+ expect(seq(at(10, sparse))).toBe("/media/matte/take-person/m00011.png");+ expect(seq(at(13, sparse))).toBe("/media/matte/take-person/m00011.png");+ expect(seq(at(14, sparse))).toBe("/media/matte/take-person/m00012.png");+ expect(seq(at(110, sparse))).toBe("/media/matte/take-person/m00023.png");+ });++ test("a file at another rate than the composition's: the matte of the file's own frame", () => {+ // a 24 fps file in a 30 fps composition: the composition's frame 30 from the start is the file's 1 s, its frame 24+ expect(seq(renderFrame(<Video src="/media/clips/take.mp4" matte={{ src: "/media/matte/t", fps: 24, count: 72 }} />, { ...opts, durationInFrames: 120, frame: 30 }))).toBe("/media/matte/t/m00025.png");+ });++ test("none without a matte; what it can't wear is said", () => {+ expect(seq(renderFrame(<Video src="/media/clips/take.mp4" />, opts))).toBeUndefined();+ expect(() => at(0, { framing: "face" })).toThrow(/can't go with framing/);+ expect(() => at(0, { matte: { src: "/media/matte/t", fps: 0, count: 3 } })).toThrow(/fps/);+ expect(() => at(0, { matte: { src: "/media/matte/t", fps: 30, count: 0 } })).toThrow(/count/);+ });+});diff --git a/sdk/raea/src/video.ts b/sdk/raea/src/video.tsindex 6bc3d158..019da895 100644--- a/sdk/raea/src/video.ts+++ b/sdk/raea/src/video.ts@@ -2,4 +2,4 @@// into it at M5; until then the old subpaths and this one export the same values.// raea/video (raea's own; Bevy has no video crate): time-shifted sequences and footage.export { Sequence, Series, Loop, Freeze, type SequenceProps, type SequenceLayout, type SeriesSequenceProps, type LoopProps, type FreezeProps } from "@raea/video/timeline";-export { Video, type VideoProps, type MediaProps } from "@raea/video/media";+export { Video, type VideoProps, type VideoMatte, type MediaProps } from "@raea/video/media";diff --git a/sdk/timeline/src/copies.ts b/sdk/timeline/src/copies.tsindex 8b41d6ea..ea5f0c74 100644--- a/sdk/timeline/src/copies.ts+++ b/sdk/timeline/src/copies.ts@@ -1,7 +1,8 @@// A composition's footage or sound played from a copy the host made of its file (raea docs/timeline.feature TL8d,// TL7k, TL7n): a sound with its noise reduced or its voice changed, footage held steady, footage with its faces// retouched. The element's src is the copy and its data-* props say what it was made from and how; its clip's props are-// a film's for the same (its own file, the copy and the settings), and a set of those is the host's edit back.+// a film's for the same (its own file, the copy and the settings), and a set of those is the host's edit back. Footage+// cut out (TL7l, TL7m) wears mattes made of what it plays, as raea's Video matte prop.import { find, type Timeline, type Value } from "./model"import type { Op } from "./ops"@@ -14,13 +15,26 @@ export interface Copied {/** what it plays is a copy of `of` with its faces retouched, each amount 0 to 1 (a <Video>'s): `of` is its file, or* its steadied copy when it is held steady too (the retouch over the steadying) */retouch?: { of: string; smooth?: number; brighten?: number; slim?: number; eyes?: number }+ /** it wears a cutout's mattes (a <Video>'s): the folder in the media folder, the file's rate, one each `every` frames,+ * how many; what they are of (person, subject or brushed) and, brushed, the second brushed at and the strokes' JSON */+ cutout?: CutoutMatte & { kind: string; at?: number; strokes?: string }}-/** The host's edits that set what an element plays: `file`, a copy of `of` made so; no `of`, `file` as it is. */+/** A cutout's mattes as a <Video>'s matte prop holds them. */+export interface CutoutMatte {+ dir: string+ fps: number+ every: number+ count: number+}++/** The host's edits that set what an element plays: `file`, a copy of `of` made so; no `of`, `file` as it is. A+ * cutout's sets the mattes it wears; with none, it wears none. */export type CopyEdit =| { op: "heard"; i: number; file: string; of?: string; denoise?: boolean; voice?: string }| { op: "steady"; i: number; file: string; of?: string; level?: string }| { op: "retouch"; i: number; file: string; of?: string; smooth?: number; brighten?: number; slim?: number; eyes?: number }+ | { op: "cutout"; i: number; kind?: string; matte?: CutoutMatte; at?: number; strokes?: string }const RETOUCH = { smooth: "retouchSmooth", brighten: "retouchBrighten", slim: "retouchSlim", eyes: "retouchEyes" } as const@@ -33,11 +47,20 @@ export function copyProps(file: string, r: Copied): Record<string, Value | boole...(r.heard && { voiced: file, denoise: !!r.heard.denoise, voice: r.heard.voice ?? "" }),...(r.steady && { stabilise: r.steady.level, steadied: r.retouch?.of ?? file }),...(r.retouch && { retouched: file, ...Object.fromEntries(Object.entries(RETOUCH).map(([k, p]) => [p, r.retouch![k as keyof typeof RETOUCH] ?? 0])) }),+ ...(r.cutout && {+ matte: r.cutout.kind,+ matted: `${r.cutout.dir}/index.json`,+ matteFps: r.cutout.fps,+ matteEvery: r.cutout.every,+ matteCount: r.cutout.count,+ ...(r.cutout.at !== undefined && { brushAt: r.cutout.at }),+ ...(r.cutout.strokes && { brushStrokes: r.cutout.strokes }),+ }),}}/** The host's edits for a set of copy props on media clips `ids` (each `i` its element's place), or undefined when `op`- * isn't one: a sound's voice (TL8d), footage held steady (TL7k) or retouched (TL7n). */+ * isn't one: a sound's voice (TL8d), footage held steady (TL7k), retouched (TL7n) or cut out (TL7l, TL7m). */export function copyEdits(t: Timeline, op: Op, ids: string[], place: (id: string) => number | undefined): CopyEdit[] | undefined {const p = op.op === "set" && Object.keys(op.set).join() === "props" ? op.set.props : undefinedif (!p) return undefined@@ -60,5 +83,19 @@ export function copyEdits(t: Timeline, op: Op, ids: string[], place: (id: stringconst amounts = Object.entries(RETOUCH).flatMap(([k, prop]) => (typeof p[prop] === "number" && (p[prop] as number) > 0 ? [[k, p[prop] as number]] : []))return { op: "retouch", i, file: String(p.retouched), of: from, ...Object.fromEntries(amounts) }})+ if (has("video", ["matte", "matted", "matteFps", "matteEvery", "matteCount", "brushAt", "brushStrokes"]))+ return each((i) => {+ const dir = typeof p.matted === "string" ? p.matted.replace(/\/index\.json$/, "") : ""+ if (!dir) return { op: "cutout", i }+ const brushed = p.matte === "brushed"+ return {+ op: "cutout",+ i,+ kind: String(p.matte ?? ""),+ matte: { dir, fps: Number(p.matteFps), every: Number(p.matteEvery ?? 1), count: Number(p.matteCount) },+ ...(brushed && typeof p.brushAt === "number" && { at: p.brushAt }),+ ...(brushed && typeof p.brushStrokes === "string" && { strokes: p.brushStrokes }),+ }+ })return undefined}diff --git a/sdk/timeline/test/read.test.ts b/sdk/timeline/test/read.test.tsindex cf743a36..7861fa0c 100644--- a/sdk/timeline/test/read.test.ts+++ b/sdk/timeline/test/read.test.ts@@ -176,6 +176,24 @@ describe("TL0c: a timeline is read from a composition", () => {expect(seqEdits(fromSequences([...rows, { ...take, name: "Audio", media: "audio" as const }], 30), on("retouch/x.mp4"))).toHaveProperty("why")})+ test("footage cut out is its <Video> wearing the mattes made of what it plays, brushed with its strokes (TL7l, TL7m)", () => {+ const take = { i: 4, name: "Video", label: "take.mp4", from: 90, to: 180, lane: 0, media: "video" as const, startFrom: 30, file: "take.mp4" }+ const t = fromSequences([...rows, take], 30)+ const made = { op: "set" as const, id: "seq-4", set: { props: { matte: "person", matted: "matte/take-person-0123456789/index.json", matteFps: 30, matteEvery: 1, matteCount: 240 } } }+ expect(seqEdits(t, made)).toEqual([{ op: "cutout", i: 4, kind: "person", matte: { dir: "matte/take-person-0123456789", fps: 30, every: 1, count: 240 } }])+ const back = fromSequences([...rows, { ...take, cutout: { dir: "matte/take-person-0123456789", fps: 30, every: 1, count: 240, kind: "person" } }], 30)+ expect(find(back, "seq-4")!.clip.props).toEqual({ file: "take.mp4", matte: "person", matted: "matte/take-person-0123456789/index.json", matteFps: 30, matteEvery: 1, matteCount: 240 })+ expect(seqEdits(back, { op: "set", id: "seq-4", set: { props: { matte: "", matted: "" } } })).toEqual([{ op: "cutout", i: 4 }])+ // brushed: the second and the strokes go with it, and come back+ const strokes = JSON.stringify([{ size: 0.05, points: [[0.5, 0.5]] }])+ const brush = { op: "set" as const, id: "seq-4", set: { props: { matte: "brushed", matted: "matte/take-brushed-abcdefabcd/index.json", matteFps: 30, matteEvery: 3, matteCount: 80, brushAt: 1.5, brushStrokes: strokes } } }+ expect(seqEdits(t, brush)).toEqual([{ op: "cutout", i: 4, kind: "brushed", matte: { dir: "matte/take-brushed-abcdefabcd", fps: 30, every: 3, count: 80 }, at: 1.5, strokes }])+ const brushedBack = fromSequences([...rows, { ...take, cutout: { dir: "matte/take-brushed-abcdefabcd", fps: 30, every: 3, count: 80, kind: "brushed", at: 1.5, strokes } }], 30)+ expect(find(brushedBack, "seq-4")!.clip.props).toMatchObject({ matte: "brushed", brushAt: 1.5, brushStrokes: strokes })+ // a sound isn't cut out+ expect(seqEdits(fromSequences([...rows, { ...take, name: "Audio", media: "audio" as const }], 30), made)).toHaveProperty("why")+ })+test("a file of the project's is a new sequence holding it; on the magnet's main track the clips after it move on and it goes in beside the one before it (TL3j)", () => {const t = fromSequences(rows, 30)const add = (kind: string, track: string, start: number, length: number, asset = "/p/media/beach.mp4") => seqEdits(t, { op: "add", kind: track, clip: { id: "m", kind, name: "beach.mp4", start, length, ...(kind !== "image" && { in: 0, source: length }), props: { asset } } })diff --git a/sdk/video/src/media.tsx b/sdk/video/src/media.tsxindex 5557949a..2df81170 100644--- a/sdk/video/src/media.tsx+++ b/sdk/video/src/media.tsx@@ -57,6 +57,33 @@ export interface VideoProps extends MediaProps {framing?: "face";/** ours: multiplies the framing's scale (1.15 is the usual) */punchIn?: number;+ /** ours: its cutout (docs/timeline.feature TL7l, CapCut's Auto cutout): the mattes made of its file, which it wears as+ * its mask, so what is cut out shows what is under it */+ matte?: VideoMatte;+}++/** A clip's mattes: PNGs whose alpha is what is kept, m00001.png on, in one folder of the media folder. */+export interface VideoMatte {+ /** the folder, as staticFile gives it: staticFile("matte/take-person") */+ src: string;+ /** the file's frame rate: m00001.png is its frame 0 */+ fps: number;+ /** one matte each `every` frames of the file, held until the next (1, every frame, when left out) */+ every?: number;+ /** how many mattes there are: past the last, the last is worn */+ count: number;+}++/** The matte `m` has for `seconds` of the file, worn where the picture is (`fit` and `place` as its objectFit and+ * objectPosition), so each pixel of the matte is over the pixel of the frame it was made from. */+export function matteStyle(m: VideoMatte, seconds: number, fit: CSSProperties["objectFit"], place: CSSProperties["objectPosition"]): CSSProperties {+ const every = m.every ?? 1;+ if (typeof m.src !== "string" || !m.src || !(m.fps > 0) || !(every >= 1) || !(m.count >= 1)) {+ throw new RangeError(`Video matte: give its folder (src), the file's fps, and count (at least 1), every 1 or more: got ${JSON.stringify(m)}`);+ }+ const i = Math.max(0, Math.min(m.count - 1, Math.floor((Math.max(0, seconds) * m.fps) / every + 1e-6)));+ const size = fit === "contain" || fit === "cover" ? fit : fit === "none" || fit === "scale-down" ? "auto" : "100% 100%";+ return { maskImage: `url(${m.src.replace(/\/$/, "")}/m${String(i + 1).padStart(5, "0")}.png)`, maskSize: size, maskPosition: String(place ?? "50% 50%"), maskRepeat: "no-repeat" };}export type AudioProps = Omit<MediaProps, "style" | "className" | "src"> & {@@ -227,7 +254,10 @@ export function Video(props: VideoProps) {// a framed Video's position is the engine's (its face track, punchIn): the centred default is left out, so only an// objectPosition the author gives wins over framingconst framed = props.framing !== undefined || props.punchIn !== undefined;- const style: CSSProperties = { objectFit: "cover", ...(framed ? {} : { objectPosition: "50% 50%" }), ...props.style };+ // (the engine places a framed take on its face, where a matte can't follow it)+ if (props.matte && framed) throw new RangeError(`Video ${props.src}: a matte is worn over the picture as it is placed, so it can't go with framing or punchIn`);+ const placed: CSSProperties = { objectFit: "cover", ...(framed ? {} : { objectPosition: "50% 50%" }), ...props.style };+ const style = props.matte ? { ...placed, ...matteStyle(props.matte, Number(attrs["data-source-time"]), placed.objectFit, placed.objectPosition) } : placed;return (<video{...attrs}