Skip to content

armgit / raea

Public Imported from GitHub
0

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.

raea frames check on raea cloud boxes: what a cut's pictures get wrong that a viewer sees at once, measured (11-25, Shane on StreetTalk's cuts: "it cuts out faces all the time and also does split frame shots when they make no sense", "it makes text too small on some things, we should have a text/glyph readability check and measurement").

shinyobjectz1a913e6b0626
diff --git a/sdk/cloud/deploy/modal/farm.py b/sdk/cloud/deploy/modal/farm.py
index d3e37f54..84ff8de0 100644
--- a/sdk/cloud/deploy/modal/farm.py
+++ b/sdk/cloud/deploy/modal/farm.py
@@ -66,6 +66,14 @@ image = (
"| tar -xJ -C /opt && ln -s /opt/blender-$v-linux-x64/blender /usr/local/bin/blender && blender -b --version | head -1",
)
.pip_install("fastapi[standard]==0.121.2")
+ # /v1/faces: OpenCV's YuNet face detector (232 KB, CPU), for the boxes' frames check (server/frames.ts): a box has
+ # no vision backend of its own (raea-perceive isn't in raea's Linux build), so a face cut by a 9:16 crop went unseen
+ .pip_install("opencv-python-headless==4.11.0.86", "numpy<2.3")
+ .run_commands(
+ "set -e; curl -fsSL -o /opt/yunet.onnx https://media.githubusercontent.com/media/opencv/opencv_zoo/main/models/"
+ "face_detection_yunet/face_detection_yunet_2023mar.onnx "
+ "&& echo '8f2383e4dd3cfbb4553ea8718107fc0423210dc964f9f4280604804ed2552fa4 /opt/yunet.onnx' | sha256sum -c"
+ )
.add_local_file(os.path.join(CLOUD, "image", "nvidia_icd.json"), "/usr/share/vulkan/icd.d/nvidia_icd.json", copy=True)
.env({"WGPU_BACKEND": "vulkan", "NVIDIA_DRIVER_CAPABILITIES": "all", "RAEA_CLIP_CHECK": "0", "RAEA_AUDIO_MUTE": "1",
"RAEA_MODELS": "/models/raea", "RAEA_FEED_MODELS": "/models/feed", "RAEA_LIBRARY_MODELS": "/models/library",
@@ -380,6 +388,49 @@ def api():
# cloud's library index uses (apps/app host/library/words.ts) hears it here. The body is one MP3 piece (16 kHz mono,
# at most 10 minutes; the box cuts the pieces), the answer its words in the piece's own seconds. 11-25, Shane: "give
# it whatever we use for indexing and libraries and sync", so agents check the words their cuts say.
+ def seams(g):
+ """a split screen's seams: rows (h) or columns (v) where the picture jumps across nearly all of the frame, as a
+ cut between two pictures does and nothing filmed does (a caption's box spans part of it, a horizon is soft)"""
+ import numpy as np
+
+ found = []
+ for axis, d in (("h", np.abs(np.diff(g, axis=0))), ("v", np.abs(np.diff(g, axis=1)).T)):
+ n = d.shape[0]
+ share = (d > 24).mean(axis=1)
+ for i in range(int(n * 0.08), int(n * 0.92)):
+ if share[i] > 0.7 and share[i] >= share[max(i - 1, 0)] and share[i] >= share[min(i + 1, n - 1)]:
+ found.append([axis, i + 1, round(float(share[i]), 2)])
+ return found
+
+ @web.post("/v1/faces")
+ async def faces(req: Request):
+ """the faces in a video's frames, for the boxes' frames check: the body is {"frames": [base64 JPEG, ...]} (at most
+ 400, any size), the answer each frame's size and its faces as [x, y, w, h, score] in that frame's pixels"""
+ import base64
+ import cv2
+ import numpy as np
+
+ check(req)
+ body = await req.json()
+ frames = body.get("frames") if isinstance(body, dict) else None
+ if not isinstance(frames, list) or not frames:
+ raise HTTPException(400, 'the body is {"frames": [base64 JPEG, ...]}')
+ if len(frames) > 400:
+ raise HTTPException(413, "at most 400 frames a call")
+ out, det, size = [], None, None
+ for b64 in frames:
+ im = cv2.imdecode(np.frombuffer(base64.b64decode(b64), np.uint8), cv2.IMREAD_COLOR)
+ if im is None:
+ out.append(None)
+ continue
+ h, w = im.shape[:2]
+ if size != (w, h):
+ det, size = cv2.FaceDetectorYN.create("/opt/yunet.onnx", "", (w, h), 0.6, 0.3, 5000), (w, h)
+ _, found = det.detect(im)
+ out.append({"w": w, "h": h, "faces": [[round(float(f[0]), 1), round(float(f[1]), 1), round(float(f[2]), 1), round(float(f[3]), 1), round(float(f[14]), 3)] for f in (found if found is not None else [])],
+ "seams": seams(cv2.cvtColor(im, cv2.COLOR_BGR2GRAY).astype(np.int16))})
+ return {"model": "yunet-2023mar", "frames": out}
+
@web.post("/v1/words")
async def words(req: Request):
import base64
diff --git a/sdk/cloud/image/raea.sh b/sdk/cloud/image/raea.sh
index ad30d1ea..494d1bfc 100644
--- a/sdk/cloud/image/raea.sh
+++ b/sdk/cloud/image/raea.sh
@@ -11,5 +11,7 @@ fi
# agents reach for, so it's the same
case "${1:-}" in
words|transcribe) exec node /opt/raea-cloud/server/words.ts "$@" ;;
+ # faces cut by the frame or a seam, text too small (server/frames.ts, the farm's face detector)
+ frames) exec node /opt/raea-cloud/server/frames.ts "$@" ;;
esac
exec /opt/raea/bin/raea "$@"
diff --git a/sdk/cloud/server/frames.ts b/sdk/cloud/server/frames.ts
new file mode 100644
index 00000000..552eb714
--- /dev/null
+++ b/sdk/cloud/server/frames.ts
@@ -0,0 +1,226 @@
+// `raea frames check` on a raea cloud box: what an export's pictures get wrong that a viewer sees at once, measured
+// (11-25, Shane: "it cuts out faces all the time and also does split frame shots when they make no sense", "it makes
+// text too small on some things, we should have a text/glyph readability check and measurement").
+//
+// raea frames check VIDEO [--manifest RENDER.json] [-o REPORT.json]
+// faces: VIDEO's frames, two a second, through the farm's face detector (POST /v1/faces, OpenCV's YuNet; a box has
+// no vision backend of its own). A face of a person in the shot (at least 6% of the frame's height) touching an
+// edge is cut by the frame: for a second or more it's an error, shorter a warning.
+// text: each text the render's manifest shows (raea render --manifest; a .tsx render through raea cloud writes
+// VIDEO.render.json by itself), its font size in pixels of a 1080-wide frame: under 40 px is an error (no one
+// reads it on a phone), under 48 px a warning (small for anything but a badge or small print).
+// Exit 1 on any error. A face at the edge that's meant (someone walking out of shot) is said, with its reason, in
+// VIDEO.despite.txt beside the video: its findings are then warnings.
+import { spawnSync } from "node:child_process"
+import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
+import os from "node:os"
+import path from "node:path"
+import { pathToFileURL } from "node:url"
+
+/** frames sampled a second, and the width they're read at (a face's place is in shares of the picture) */
+const RATE = 2
+const SIDE = 540
+/** a face this share of the frame's height or more is someone in the shot, not a passer-by far behind (a split
+ * screen's half holds a face about this big) */
+export const FACE_MIN = 0.05
+/** least font sizes, in pixels of a frame 1080 wide (its shorter side): the Direct Response skill's table */
+export const TEXT_ERROR = 40
+export const TEXT_WARN = 48
+
+export type Finding = { level: "error" | "warn"; kind: "face-cut" | "split" | "text-small"; at: number | null; until?: number; says: string }
+/** a line where the picture jumps across nearly the whole frame (the farm's): its axis (h, a row), where, and its share */
+export type Seam = [string, number, number]
+export type Faces = { w: number; h: number; faces: number[][]; seams?: Seam[] } | null
+type Split = { axis: "h" | "v"; at: number }
+
+/** a frame's split-screen seams: lone lines in its middle 60% (a bar's two edges close together are a caption's box, a
+ * badge or a letterbox, not a seam) */
+export function splitsOf(fr: NonNullable<Faces>): Split[] {
+ const out: Split[] = []
+ for (const axis of ["h", "v"] as const) {
+ const dim = axis === "h" ? fr.h : fr.w
+ const at = [...new Set((fr.seams ?? []).filter((x) => x[0] === axis).map((x) => x[1]))].sort((a, b) => a - b)
+ const lines = at.filter((y, i) => i === 0 || y - at[i - 1] > 4)
+ for (const y of lines) {
+ const bar = lines.some((o) => o !== y && Math.abs(o - y) < dim * 0.15)
+ if (!bar && y > dim * 0.2 && y < dim * 0.8) out.push({ axis, at: y })
+ }
+ }
+ return out
+}
+
+const near = (a: Split, b: Split) => a.axis === b.axis && Math.abs(a.at - b.at) <= 6
+const big = (fr: NonNullable<Faces>) => fr.faces.filter((f) => f[3] >= fr.h * FACE_MIN)
+
+/** what cuts a face in a frame: an edge of the frame, or a split screen's seam */
+function cutBy(fr: NonNullable<Faces>, splits: Split[]): string | null {
+ for (const [x, y, fw, fh] of big(fr)) {
+ if (x <= 1) return "the left edge"
+ if (x + fw >= fr.w - 1) return "the right edge"
+ if (y <= 1) return "the top edge"
+ if (y + fh >= fr.h - 1) return "the bottom edge"
+ for (const sp of splits) {
+ const [a, b] = sp.axis === "h" ? [y, y + fh] : [x, x + fw]
+ if ((a < sp.at - 2 && b > sp.at + 2) || Math.abs(b - sp.at) <= 3 || Math.abs(a - sp.at) <= 3) return "the split screen's seam"
+ }
+ }
+ return null
+}
+
+/** runs of the same thing in consecutive frames, as [from, to) in frames */
+function runs<T>(xs: (T | null)[], same: (a: T, b: T) => boolean = (a, b) => a === b): [number, number, T][] {
+ const out: [number, number, T][] = []
+ for (let i = 0; i < xs.length; ) {
+ const x = xs[i]
+ if (x === null) {
+ i++
+ continue
+ }
+ let j = i + 1
+ while (j < xs.length && xs[j] !== null && same(x, xs[j] as T)) j++
+ out.push([i, j, x])
+ i = j
+ }
+ return out
+}
+
+/** faces cut by the frame's edges or a split screen's seam (a second or more an error, shorter a warning), and split
+ * screens that hold one person (a split is for two things at once) */
+export function cutFaces(frames: Faces[], rate = RATE): Finding[] {
+ const raw = frames.map((fr) => (fr ? splitsOf(fr) : []))
+ // a seam held for a second or more: a split screen; a line for a frame is a cut or a flash
+ const held = raw.map((ss, i) => ss.filter((s) => (raw[i - 1] ?? []).some((o) => near(s, o)) || (raw[i + 1] ?? []).some((o) => near(s, o))))
+ const out: Finding[] = []
+ const hits = frames.map((fr, i) => (fr ? cutBy(fr, held[i]) : null))
+ for (const [i, j, by] of runs(hits)) {
+ const from = i / rate
+ const to = j / rate
+ out.push({ level: to - from >= 1 ? "error" : "warn", kind: "face-cut", at: from, until: to, says: `a face is cut by ${by} from ${from.toFixed(1)} s to ${to.toFixed(1)} s: reframe on the person (both eyes, mouth and chin inside the picture)${by.includes("seam") ? ", or cut between two singles" : " or cut away"}` })
+ }
+ const split = held.map((ss) => ss[0] ?? null)
+ for (const [i, j, sp] of runs(split, near)) {
+ if (j - i < 2) continue
+ // whose face is on each side of the seam, frame by frame
+ let one = 0
+ let any = 0
+ for (let k = i; k < j; k++) {
+ const fr = frames[k]
+ if (!fr) continue
+ const sides = new Set(big(fr).map(([x, y, fw, fh]) => ((sp.axis === "h" ? y + fh / 2 : x + fw / 2) < sp.at ? 0 : 1)))
+ if (sides.size) any++
+ if (sides.size === 1) one++
+ }
+ const from = i / rate
+ const to = j / rate
+ const where = sp.axis === "h" ? "top and bottom" : "side by side"
+ if (any && one * 2 > any) out.push({ level: "warn", kind: "split", at: from, until: to, says: `a split screen (${where}) from ${from.toFixed(1)} s to ${to.toFixed(1)} s shows a face in only one half: split only for two things at once (two people reacting, a face and the product), else cut between singles` })
+ }
+ return out
+}
+
+/** texts under the size floor, from a render manifest: each text once, at its first frame */
+export function smallText(manifest: any): Finding[] {
+ const w = Number(manifest?.width) || 1080
+ const h = Number(manifest?.height) || 1920
+ const fps = Number(manifest?.fps) || 30
+ const scale = 1080 / Math.min(w, h)
+ const seen = new Map<string, { at: number; px: number }>()
+ for (const fr of (manifest?.frames ?? []) as any[]) {
+ for (const t of (fr?.text ?? []) as any[]) {
+ const text = String(t?.text ?? "").trim()
+ if (!text || (t?.opacity ?? 1) <= 0.05) continue
+ const px = Number(t?.size) * scale
+ if (!Number.isFinite(px) || px <= 0) continue
+ const was = seen.get(text)
+ if (!was || px > was.px) seen.set(text, { at: was?.at ?? Number(fr?.frame ?? 0) / fps, px })
+ }
+ }
+ const out: Finding[] = []
+ for (const [text, { at, px }] of seen) {
+ const q = text.length > 40 ? `"${text.slice(0, 40)}..."` : `"${text}"`
+ if (px < TEXT_ERROR) out.push({ level: "error", kind: "text-small", at, says: `${q} is ${px.toFixed(0)} px (in a 1080-wide frame): under ${TEXT_ERROR} px no one reads it on a phone. Make it bigger, or cut words so it fits bigger` })
+ else if (px < TEXT_WARN) out.push({ level: "warn", kind: "text-small", at, says: `${q} is ${px.toFixed(0)} px: small for anything but a badge or small print (captions 52 px, hooks 64 px)` })
+ }
+ return out.sort((a, b) => (a.at ?? 0) - (b.at ?? 0))
+}
+
+function ffmpeg(args: string[]) {
+ const r = spawnSync("ffmpeg", args, { encoding: "utf8" })
+ if (r.status !== 0) throw new Error(`ffmpeg: ${(r.stderr ?? "").slice(-400)}`)
+}
+
+/** VIDEO's faces, two frames a second, by the farm */
+export async function faces(file: string, f: typeof fetch = fetch): Promise<Faces[]> {
+ const url = process.env.RAEA_CLOUD_GPU_URL
+ const token = process.env.RAEA_CLOUD_GPU_TOKEN ?? ""
+ if (!url) throw new Error("the faces check needs the farm (RAEA_CLOUD_GPU_URL); this box has none set")
+ const dir = mkdtempSync(path.join(os.tmpdir(), "raea-frames-"))
+ try {
+ ffmpeg(["-v", "error", "-y", "-i", file, "-vf", `fps=${RATE},scale='if(gt(iw,ih),-2,${SIDE})':'if(gt(iw,ih),${SIDE},-2)'`, "-q:v", "4", path.join(dir, "f%05d.jpg")])
+ const jpgs = readdirSync(dir).filter((n) => n.endsWith(".jpg")).sort()
+ const out: Faces[] = []
+ for (let i = 0; i < jpgs.length; i += 300) {
+ const body = JSON.stringify({ frames: jpgs.slice(i, i + 300).map((n) => readFileSync(path.join(dir, n)).toString("base64")) })
+ let r: Response | undefined
+ let why = ""
+ for (let k = 0; k < 4; k++) {
+ r = await f(`${url.replace(/\/$/, "")}/v1/faces`, { method: "POST", headers: { authorization: `Bearer ${token}`, "content-type": "application/json" }, body, signal: AbortSignal.timeout(300_000) })
+ if (r.ok) break
+ why = `${r.status} ${(await r.text()).slice(0, 300)}`
+ if (r.status < 500) break
+ await new Promise((ok) => setTimeout(ok, 1000 * 2 ** k))
+ }
+ if (!r?.ok) throw new Error(`the farm couldn't look at ${path.basename(file)}: ${why}`)
+ out.push(...((await r.json()) as { frames: Faces[] }).frames)
+ }
+ return out
+ } finally {
+ rmSync(dir, { recursive: true, force: true })
+ }
+}
+
+function flag(args: string[], name: string): string | undefined {
+ const i = args.indexOf(name)
+ return i >= 0 ? args[i + 1] : undefined
+}
+
+/** the manifest a render of VIDEO wrote: --manifest, or VIDEO.render.json beside it */
+export const manifestOf = (video: string) => `${video.slice(0, video.length - path.extname(video).length)}.render.json`
+
+export async function main(args: string[]): Promise<number> {
+ const a = args[0] === "check" ? args.slice(1) : args
+ const video = a.find((x, i) => !x.startsWith("-") && !["--manifest", "-o"].includes(a[i - 1] ?? ""))
+ if (!video || !existsSync(video)) {
+ console.error("usage: raea frames check VIDEO [--manifest RENDER.json] [-o REPORT.json] (faces cut by the frame, and text too small to read)")
+ return 2
+ }
+ const m = flag(a, "--manifest") ?? manifestOf(video)
+ const found: Finding[] = []
+ let looked = 0
+ try {
+ const fr = await faces(video)
+ looked = fr.length
+ found.push(...cutFaces(fr))
+ } catch (e) {
+ console.log(`WARN the faces check couldn't run: ${(e as Error).message}`)
+ }
+ const texts = existsSync(m) ? smallText(JSON.parse(readFileSync(m, "utf8"))) : null
+ if (texts) found.push(...texts)
+ const despite = `${video.slice(0, video.length - path.extname(video).length)}.despite.txt`
+ const why = existsSync(despite) ? readFileSync(despite, "utf8").trim() : ""
+ const out = found.map((x) => (why && x.kind === "face-cut" ? { ...x, level: "warn" as const, says: `${x.says} (despite: ${why.slice(0, 200)})` } : x)).sort((p, q) => (p.at ?? 0) - (q.at ?? 0))
+ for (const x of out) console.log(`${x.level === "error" ? "ERROR" : "WARN "} ${x.at === null ? "" : `${x.at.toFixed(1)} s `}${x.says}`)
+ const errors = out.filter((x) => x.level === "error").length
+ const report = flag(a, "-o") ?? `${video.slice(0, video.length - path.extname(video).length)}.frames-check.json`
+ writeFileSync(report, JSON.stringify({ video, looked_at: looked, text_checked: texts !== null, findings: out }, null, 1))
+ console.log(`${errors ? "FAILED" : "PASSED"} ${path.basename(video)}: ${looked} frames looked at for faces, ${texts === null ? "no manifest for its text" : `${new Set(texts.map((t) => t.says)).size} small texts`}, ${errors} errors, ${out.length - errors} warnings; ${path.basename(report)}`)
+ return errors ? 1 : 0
+}
+
+if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {
+ const a = process.argv.slice(2)
+ main(a[0] === "frames" ? a.slice(1) : a).then(
+ (c) => process.exit(c),
+ (e) => (console.error(`raea frames: ${(e as Error).message}`), process.exit(1)),
+ )
+}
diff --git a/sdk/cloud/server/offload.ts b/sdk/cloud/server/offload.ts
index 7f8c11c1..c5fd692e 100644
--- a/sdk/cloud/server/offload.ts
+++ b/sdk/cloud/server/offload.ts
@@ -87,6 +87,14 @@ export function plan(args: string[], cwd: string, root?: string): Plan | string
async function main() {
const args = process.argv.slice(2)
+ // a video's render manifest (every text's size and place, frame by frame) beside it, for the frames check's text
+ // sizes (frames.ts), unless the render already asks for one
+ {
+ const oi = args.indexOf("-o")
+ const o = oi >= 0 ? (args[oi + 1] ?? "") : ""
+ if (args[0] === "render" && /\.(mp4|mov|m4v|webm)$/i.test(o) && !args.includes("--manifest") && process.env.RAEA_CLOUD_FRAMES !== "0")
+ args.push("--manifest", `${o.slice(0, o.length - path.extname(o).length)}.render.json`)
+ }
const url = process.env.RAEA_CLOUD_GPU_URL
const token = process.env.RAEA_CLOUD_GPU_TOKEN ?? ""
if (!url) local(args)
@@ -184,6 +192,18 @@ async function main() {
const code = await afterRender(made, say)
if (code) process.exitCode = code
}
+ // what its pictures get wrong (frames.ts): faces cut by the frame or a split screen's seam, text too small to read
+ // (11-25, Shane: "it cuts out faces all the time", "it makes text too small")
+ if (!exit && /\.(mp4|mov|m4v|webm)$/i.test(made) && existsSync(made) && process.env.RAEA_CLOUD_FRAMES !== "0") {
+ const { main: frames } = await import("./frames.ts")
+ say(`the frames check: ${path.basename(made)}'s faces and text sizes`)
+ const mi = args.indexOf("--manifest")
+ const code = await frames(["check", made, ...(mi >= 0 ? ["--manifest", path.resolve(process.cwd(), args[mi + 1] ?? "")] : [])]).catch((e) => (say(`the frames check couldn't run: ${(e as Error).message}`), 0))
+ if (code) {
+ say(`${path.basename(made)} has a face cut or text too small: fix every ERROR above (reframe on the person, make the text bigger), then render again. A face at the edge that's meant goes in ${path.basename(made, path.extname(made))}.despite.txt with why`)
+ process.exitCode = code
+ }
+ }
} finally {
rmSync(tmp, { recursive: true, force: true })
}
diff --git a/sdk/cloud/test/units.ts b/sdk/cloud/test/units.ts
index aaff179d..aa5058cb 100644
--- a/sdk/cloud/test/units.ts
+++ b/sdk/cloud/test/units.ts
@@ -7,6 +7,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"
import os from "node:os"
import path from "node:path"
import { parseSummary, pick } from "../server/gpu.ts"
+import { cutFaces, smallText, splitsOf } from "../server/frames.ts"
import { plan, projectRoot } from "../server/offload.ts"
import { shellEnv } from "../server/shell-os.ts"
import { landedQuery, linkIn, packCredential, unpackCredential } from "../server/google-token.ts"
@@ -106,3 +107,31 @@ console.log("units: ok")
rmSync(other, { recursive: true, force: true })
console.log("ok google-token")
}
+
+{
+ // frames.ts: a face at the frame's edge for a second is an error, for half a second a warning; a face too small to be
+ // someone in the shot is left alone
+ const fr = (faces: number[][], seams: [string, number, number][] = []) => ({ w: 540, h: 960, faces, seams })
+ const edge = [0, 400, 40, 90, 0.9]
+ const whole = [200, 300, 80, 100, 0.9]
+ let f = cutFaces([fr([whole]), fr([edge]), fr([edge]), fr([whole]), fr([edge]), fr([[0, 50, 10, 12, 0.9]])])
+ assert.deepEqual(f.map((x) => [x.level, x.at, x.until]), [["error", 0.5, 1.5], ["warn", 2, 2.5]])
+ assert.match(f[0].says, /left edge/)
+ // a split screen: a lone line held; a caption's box (two lines close together) isn't one
+ assert.deepEqual(splitsOf(fr([], [["h", 480, 0.8]])), [{ axis: "h", at: 480 }])
+ assert.deepEqual(splitsOf(fr([], [["h", 446, 0.8], ["h", 513, 0.8]])), [])
+ assert.deepEqual(splitsOf(fr([], [["h", 60, 0.9]])), [], "near the edge: a letterbox or a header")
+ const seam: [string, number, number][] = [["h", 480, 0.8]]
+ f = cutFaces([fr([[200, 430, 80, 50, 0.9]], seam), fr([[200, 430, 80, 50, 0.9]], seam), fr([[200, 430, 80, 50, 0.9]], seam)])
+ assert.ok(f.some((x) => x.kind === "face-cut" && /seam/.test(x.says) && x.level === "error"))
+ f = cutFaces([fr([[200, 200, 80, 100, 0.9]], seam), fr([[200, 200, 80, 100, 0.9]], seam), fr([[200, 200, 80, 100, 0.9]], seam)])
+ assert.deepEqual(f.map((x) => x.kind), ["split"], "one face over a split: a split for nothing")
+ f = cutFaces([0, 1, 2].map(() => fr([[200, 200, 80, 100, 0.9], [200, 650, 80, 100, 0.9]], seam)))
+ assert.deepEqual(f, [], "two people, one each side")
+ // text sizes in pixels of a 1080-wide frame: a 720-wide render's 28 px is 42 px
+ const m = (w: number, size: number) => ({ width: w, height: (w * 16) / 9, fps: 30, frames: [{ frame: 0, text: [{ text: "Not for surgeries", size, opacity: 1 }] }] })
+ assert.equal(smallText(m(1080, 28))[0].level, "error")
+ assert.equal(smallText(m(720, 28))[0].level, "warn")
+ assert.deepEqual(smallText(m(1080, 64)), [])
+ console.log("ok frames")
+}