mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-06 05:33:38 -10:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ea66741a0 | ||
|
|
dbee528778 | ||
|
|
bad441493e | ||
|
|
14a10fc2b0 | ||
|
|
02617df030 |
No files matched your search
@@ -1,7 +1,7 @@
|
||||
// pace.ts on made-up words and levels: a short run between two long pauses joins a neighbour; level evening measures
|
||||
// only clips with a second of speech and gives a short clip its own take's gain
|
||||
import { expect, test } from "bun:test";
|
||||
import { evenLevels, pace, type Levels } from "../src/pace";
|
||||
import { evenLevels, linesIn, pace, unsqueezed, type Levels } from "../src/pace";
|
||||
|
||||
/** levels at 10 ms: speech (-20 dB) inside each word, quiet (-70 dB) elsewhere, over `seconds` */
|
||||
function levels(ws: { from: number; to: number }[], seconds: number): Levels {
|
||||
@@ -66,3 +66,15 @@ test("a line stopping mid-sentence with no pause runs on to its sentence's end;
|
||||
const r = pace(long, l2, [[0, 2]], { hook: 0 });
|
||||
expect(r.pieces[0].to).toBeLessThanOrEqual(1.06 + 1 / 30);
|
||||
});
|
||||
|
||||
test("a phrase a transcriber heard twice and squeezed into one instant is dropped, and the line is found where it was said", () => {
|
||||
// 12-05, run 28: "Sign up for the news, sign up for the newsletter", with "up for the news sign" all at 10.32-10.34 s
|
||||
const w = (text: string, a: number, b: number) => ({ text, from: a / 1000, to: b / 1000 });
|
||||
const heard = [w("for", 9280, 9360), w("the", 9360, 9440), w("newsletter.", 9440, 9460), w("Sign", 10080, 10320), w("up", 10320, 10340), w("for", 10320, 10340), w("the", 10320, 10340), w("news", 10320, 10340), w("sign", 10320, 10340), w("up", 10320, 10400), w("for", 10400, 10560), w("the", 10560, 10640), w("newsletter", 10640, 10960)];
|
||||
const ws = unsqueezed(heard);
|
||||
expect(ws.map((x) => x.text).join(" ")).toBe("for the newsletter. Sign up for the newsletter");
|
||||
const { spans } = linesIn(ws, ["sign up for the newsletter"]);
|
||||
expect(ws[spans[0][0]].from).toBe(10.08);
|
||||
// two short words together are speech, kept
|
||||
expect(unsqueezed([w("a", 0, 20), w("cat", 20, 40), w("sat", 300, 500)]).length).toBe(3);
|
||||
});
|
||||
@@ -255,6 +255,44 @@ ${Array.from({ length: 40 }, (_, i) => `.u${i} { margin: ${i}px; }`).join("\n")}
|
||||
}
|
||||
});
|
||||
|
||||
// a take's jump cuts read through the ffmpeg CLI (cutplan.ts ffmpegCuts): where raea media cuts finds them
|
||||
test.skipIf(spawnSync("ffmpeg", ["-version"]).status !== 0)("raea cut reads a take's jump cuts through ffmpeg, where the engine finds them", async () => {
|
||||
const { ffmpegCuts } = await import("../src/cutplan.ts");
|
||||
const dir = mkdtempSync(join(tmpdir(), "raea-ffcuts-"));
|
||||
try {
|
||||
const color = (c: string) => ["-f", "lavfi", "-i", `color=c=${c}:s=320x180:r=30:d=2`];
|
||||
spawnSync("ffmpeg", ["-v", "error", "-y", ...color("red"), ...color("blue"), ...color("green"), "-filter_complex", "[0][1][2]concat=n=3:v=1:a=0", "-c:v", "libx264", "-pix_fmt", "yuv420p", join(dir, "t.mp4")]);
|
||||
expect(ffmpegCuts(join(dir, "t.mp4"), 0.08)).toEqual([2, 4]);
|
||||
expect(ffmpegCuts(join(dir, "missing.mp4"), 0.08)).toBeNull();
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
// raea cloud's footage/faces.json (prep's faces, found on its farm): perception.json takes each clip's face from it,
|
||||
// with no still and no raea-perceive (a box has none). A made clip and made-up faces, never real footage
|
||||
test.skipIf(spawnSync("ffmpeg", ["-version"]).status !== 0)("raea cut takes each clip's face from footage/faces.json", () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), "raea-cut-faces-"));
|
||||
const run = (...a: string[]) => spawnSync("bun", [join(here, "src/native.ts"), bin, ...a], { cwd: dir, encoding: "utf8", env: { ...process.env, RAEA_PERCEIVE: "/nonexistent/raea-perceive" } });
|
||||
try {
|
||||
mkdirSync(join(dir, "media"));
|
||||
mkdirSync(join(dir, "footage"));
|
||||
spawnSync("ffmpeg", ["-v", "error", "-y", "-f", "lavfi", "-i", "color=c=gray:s=160x120:r=30:d=4", "-c:v", "libx264", "-pix_fmt", "yuv420p", join(dir, "media/take01.mp4")]);
|
||||
const said: [string, number, number][] = [["Hello", 200, 600], ["there.", 650, 1000], ["This", 1500, 1700], ["is", 1750, 1850], ["the", 1900, 2000], ["second", 2100, 2500], ["line.", 2550, 2900]];
|
||||
writeFileSync(join(dir, "media/take01.words.json"), JSON.stringify(said.map(([text, start_ms, end_ms]) => ({ text, start_ms, end_ms }))));
|
||||
// no face by the first clip's middle (0.6 s, nearest 1 s); two at 2 s, by the second's (2.4 s): the larger is kept
|
||||
const face = [0.25, 0.25, 0.5, 0.5, 0.9];
|
||||
writeFileSync(join(dir, "footage/faces.json"), JSON.stringify({ take01: { w: 160, h: 120, t: [0, 1, 2, 3], s: [[], [], [[0.1, 0.1, 0.1, 0.1, 0.99], face], [face]] } }));
|
||||
const r = run("cut", "take01", "hello there", "the second line");
|
||||
expect(r.stderr).toBe("");
|
||||
const band = { safe: { top: 220, bottom: 1500 } };
|
||||
// 160x120 covering 1080x1920 is 16x, centred: x 0.25*160*16 - 740, y 0.25*120*16, w 0.5*160*16, h 0.5*120*16
|
||||
expect(JSON.parse(readFileSync(join(dir, "perception.json"), "utf8"))).toEqual({ "0": band, "33": { ...band, face: { x: -100, y: 480, w: 1280, h: 960 } } });
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
// a stock talking take (fixtures/CREDITS.md): the face branch of frame and perception.json. The footage fixtures are
|
||||
// the maintainers' (tools/public-first/private.paths), so a checkout without them skips this
|
||||
test.skipIf(!existsSync(join(raea, "engine/media/fixtures")))("raea frame and raea cut find the face in a talking take", () => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// How raea cut times a take's lines: the take's light copy when raea cloud keeps one, its jump cuts (kept in raea's
|
||||
// cache) and sound level, and pace.ts's timing, kept off the take's own jump cuts. native.ts gives it the engine.
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { createHash } from "node:crypto";
|
||||
import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
||||
import { homedir, tmpdir } from "node:os";
|
||||
@@ -11,6 +12,35 @@ export type TakeIO = { at: (p: string) => string; engineRun: (a: string[]) => st
|
||||
|
||||
const ms = (s: number) => Math.round(s * 1000) / 1000;
|
||||
|
||||
/** A take's jump cuts read through the ffmpeg CLI where there is one: its luma at 160x90, every frame, scored as raea
|
||||
* media cuts scores them (ffmpeg's select scene: each frame's mean absolute difference from the last, less the
|
||||
* difference before it, over 100). ffmpeg decodes on every core; the engine's own decoder on a Linux box is openh264 on
|
||||
* one (12-05: 38 s for a 3.5-minute light copy, 66 s for a 6-minute one, against 4 s for ffmpeg), and a box step has
|
||||
* 3 minutes. The small picture leaves a hard cut's score where it was and a frame's grain out. null where ffmpeg
|
||||
* can't read it: the engine reads it then. */
|
||||
export function ffmpegCuts(file: string, threshold: number): number[] | null {
|
||||
const [w, h] = [160, 90];
|
||||
const r = spawnSync("ffmpeg", ["-v", "info", "-nostats", "-i", file, "-an", "-vf", `scale=${w}:${h}:flags=area,format=gray,showinfo`, "-f", "rawvideo", "-"], { maxBuffer: 1 << 30 });
|
||||
if (r.error || r.status !== 0 || !r.stdout?.length) return null;
|
||||
// each frame's time, from showinfo's lines in order
|
||||
const times = [...String(r.stderr).matchAll(/\bn:\s*\d+\s+pts:\s*-?\d+\s+pts_time:(-?[\d.]+)/g)].map((m) => Number(m[1]));
|
||||
const n = w * h;
|
||||
const frames = Math.floor(r.stdout.length / n);
|
||||
if (!frames || times.length !== frames) return null;
|
||||
const y = r.stdout as Buffer;
|
||||
const out: number[] = [];
|
||||
let prev = 0;
|
||||
for (let f = 1; f < frames; f++) {
|
||||
let sad = 0;
|
||||
for (let i = f * n, j = (f - 1) * n, e = i + n; i < e; i++, j++) sad += Math.abs(y[i] - y[j]);
|
||||
const mafd = sad / n;
|
||||
const score = Math.min(Math.max(Math.min(mafd, Math.abs(mafd - prev)) / 100, 0), 1);
|
||||
prev = mafd;
|
||||
if (score > threshold) out.push(ms(times[f]));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** cutPlan and takeLevels over `io`, each take's levels kept for the run */
|
||||
export function timing({ at, engineRun, engineJson, isAudio }: TakeIO) {
|
||||
/** The take to read for timing: its light copy when raea cloud keeps one (.raea-cloud/proxies/NAME.mp4 in the project,
|
||||
@@ -37,7 +67,7 @@ export function timing({ at, engineRun, engineJson, isAudio }: TakeIO) {
|
||||
} catch {
|
||||
kept = "";
|
||||
}
|
||||
const cuts = (engineJson(["media", "cuts", file, "--threshold", "0.08"]).cuts as { at: number }[]).map((c) => c.at);
|
||||
const cuts = ffmpegCuts(file, 0.08) ?? (engineJson(["media", "cuts", file, "--threshold", "0.08"]).cuts as { at: number }[]).map((c) => c.at);
|
||||
if (kept)
|
||||
try {
|
||||
mkdirSync(dirname(kept), { recursive: true });
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// A take's faces from raea cloud's footage/faces.json, for raea cut's perception.json (native.ts perception)
|
||||
import { readFileSync } from "node:fs";
|
||||
import { basename, extname } from "node:path";
|
||||
|
||||
type Box = { x: number; y: number; w: number; h: number };
|
||||
|
||||
/** footage/faces.json in the project (raea cloud's prep: each take's faces about once a second, found on its farm, as
|
||||
* shares of the take's picture, [x, y, w, h, score] each), read once. A box has no raea-perceive, so a still per clip
|
||||
* found no face there and cost each `raea cut --append` every earlier clip's lookup again (12-05: a step of 13 cuts ran
|
||||
* past a box's 3 minutes, and no cut on a box had a face in its perception.json) */
|
||||
let facesKept: Record<string, { w?: number; h?: number; t?: number[]; s?: number[][][] }> | null | undefined;
|
||||
function facesFile() {
|
||||
if (facesKept === undefined)
|
||||
try {
|
||||
facesKept = JSON.parse(readFileSync(`${process.cwd()}/footage/faces.json`, "utf8"));
|
||||
} catch {
|
||||
facesKept = null;
|
||||
}
|
||||
return facesKept;
|
||||
}
|
||||
|
||||
/** The largest face at the sample of faces.json nearest `t` (never one more than 1.5 s away), with the take's size: a
|
||||
* face, none there (face undefined), or null when faces.json doesn't hold the take */
|
||||
export function faceKept(file: string, t: number): { face?: Box; sw: number; sh: number } | null {
|
||||
const take = facesFile()?.[basename(file, extname(file))];
|
||||
const ts = take?.t, ss = take?.s;
|
||||
if (!take || !Array.isArray(ts) || !Array.isArray(ss) || !ts.length || !take.w || !take.h) return null;
|
||||
let k = 0;
|
||||
ts.forEach((x, i) => {
|
||||
if (Math.abs(x - t) < Math.abs(ts[k] - t)) k = i;
|
||||
});
|
||||
if (Math.abs(ts[k] - t) > 1.5) return null;
|
||||
const faces = (ss[k] ?? []).filter((f) => Array.isArray(f) && f.length >= 4);
|
||||
if (!faces.length) return { sw: take.w, sh: take.h };
|
||||
const [x, y, w, h] = faces.reduce((a, b) => (b[2] * b[3] > a[2] * a[3] ? b : a));
|
||||
return { face: { x, y, w, h }, sw: take.w, sh: take.h };
|
||||
}
|
||||
@@ -10,8 +10,9 @@ import { basename, delimiter, dirname, extname } from "node:path";
|
||||
import { brandKit, pixelsOf } from "./brand";
|
||||
import { readSite, stylesOf } from "./scrape";
|
||||
import { wordsOf } from "./heard";
|
||||
import { evenLevels, markJumps, speechOf, toSound, type PaceOptions } from "./pace";
|
||||
import { evenLevels, unsqueezed, linesIn, markJumps, speechOf, toSound, type PaceOptions } from "./pace";
|
||||
import { timing } from "./cutplan";
|
||||
import { faceKept } from "./faces";
|
||||
import { harness, library, show, task } from "./app";
|
||||
import { fromCwd } from "./show";
|
||||
import { clothesHost } from "./wardrobe";
|
||||
@@ -90,9 +91,11 @@ function words(take: string, hear = false): Word[] {
|
||||
if (!hear) return [];
|
||||
hearTake(take, file);
|
||||
}
|
||||
return (JSON.parse(readFileSync(file, "utf8")) as { text: string; start_ms: number; end_ms: number }[])
|
||||
.filter((w) => w.text?.trim())
|
||||
.map((w) => ({ text: w.text.trim(), from: w.start_ms / 1000, to: w.end_ms / 1000 }));
|
||||
return unsqueezed(
|
||||
(JSON.parse(readFileSync(file, "utf8")) as { text: string; start_ms: number; end_ms: number }[])
|
||||
.filter((w) => w.text?.trim())
|
||||
.map((w) => ({ text: w.text.trim(), from: w.start_ms / 1000, to: w.end_ms / 1000 })),
|
||||
);
|
||||
}
|
||||
|
||||
/** A tool a clean Mac lacks, found or installed once by raea's tools/ensure.sh (docs/app.feature AP6), which sits in
|
||||
@@ -275,8 +278,10 @@ function perception(edit: { width: number; height: number; fps: number }, clips:
|
||||
if (!seen.has(key)) {
|
||||
let face: Box | undefined;
|
||||
try {
|
||||
const f = faceAt(c.file, mid);
|
||||
const { sw, sh } = probeOf(c.file);
|
||||
// faces.json's when it holds the take, else a still of it read here
|
||||
const kept = faceKept(c.file, mid);
|
||||
const f = kept ? kept.face : faceAt(c.file, mid);
|
||||
const { sw, sh } = kept ?? probeOf(c.file);
|
||||
if (f && sw && sh) {
|
||||
const s = Math.max(edit.width / sw, edit.height / sh);
|
||||
const [ox, oy] = [(edit.width - sw * s) / 2, (edit.height - sh * s) / 2];
|
||||
|
||||
@@ -18,6 +18,23 @@
|
||||
|
||||
/** a word in its take's seconds */
|
||||
export type Word = { text: string; from: number; to: number };
|
||||
|
||||
/** A transcript's words less the runs it squeezed: three or more words each SQUEEZED s long or less, all starting within
|
||||
* 50 ms of the first. No one says three words in 50 ms; a transcriber writes them when it hears a phrase twice and
|
||||
* times the copy at one instant (12-05, run 28: Body Shop's "Sign up for the news, sign up for the newsletter" came
|
||||
* as "Sign up for the news sign up for the newsletter" with "up for the news sign" all at 10.32-10.34 s, raea cut took
|
||||
* the line from that "sign", and the CTA clip started inside "up") */
|
||||
export const SQUEEZED = 0.03;
|
||||
export function unsqueezed<W extends Word>(ws: W[]): W[] {
|
||||
const out: W[] = [];
|
||||
for (let i = 0; i < ws.length; ) {
|
||||
let j = i;
|
||||
while (j < ws.length && ws[j].to - ws[j].from <= SQUEEZED && ws[j].from - ws[i].from <= 0.05) j++;
|
||||
if (j - i >= 3) i = j;
|
||||
else out.push(ws[i++]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
/** a take's sound level every 10 ms (dB), from `start` seconds */
|
||||
export type Levels = { start: number; db: number[] };
|
||||
/** a stretch of quiet in a take: from its first quiet 10 ms to the first sound after it (s) */
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# MODAL_PROFILE=raea modal deploy deploy/modal/farm.py
|
||||
#
|
||||
# POST /v1/jobs?args=JSON[&gpus=N][&gpu=KIND][&max_usd=X] body: the project as a tar. {id}
|
||||
# POST /v1/jobs?args=JSON[&gpus=N][&gpu=KIND][&max_usd=X][&nv=1|0] body: the project as a tar. {id}
|
||||
# GET /v1/jobs/ID?from=N {log, next, exit?}, held up to 20 s for more
|
||||
# GET /v1/jobs/ID/out?as=zst|gz|tar the files the job made or changed; the job is removed
|
||||
# GET /v1/jobs/ID/media with media=1: the job's media outputs [{path, oid, size}],
|
||||
@@ -814,7 +814,7 @@ def api():
|
||||
if not isinstance(args, list) or not all(isinstance(a, str) for a in args):
|
||||
raise HTTPException(400, "args must be a JSON array of strings: raea's own arguments")
|
||||
q = req.query_params
|
||||
opts = {"gpus": min(int(q.get("gpus", JOB_GPUS)), GPUS), "cpus": min(int(q.get("cpus", JOB_CPUS)), CPUS), "kept": q.get("kept", "1") != "0", "gpu": q.get("gpu"), "max_usd": float(q["max_usd"]) if "max_usd" in q else None, "media": q.get("media") == "1"}
|
||||
opts = {"gpus": min(int(q.get("gpus", JOB_GPUS)), GPUS), "cpus": min(int(q.get("cpus", JOB_CPUS)), CPUS), "kept": q.get("kept", "1") != "0", "gpu": q.get("gpu"), "nv": q.get("nv") if q.get("nv") in ("0", "1") else None, "max_usd": float(q["max_usd"]) if "max_usd" in q else None, "media": q.get("media") == "1"}
|
||||
id = str(uuid.uuid4())
|
||||
work = f"{JOBS}/{id}/work"
|
||||
async with gate.use():
|
||||
|
||||
@@ -365,7 +365,7 @@ def raea_render(args, opts, work, log, render, cpu_env, run, reload=lambda: None
|
||||
t = threading.Thread(target=lambda: run(["raea", *rest, "-o", sound], cwd=work, env=cpu_env))
|
||||
t.start()
|
||||
video = out.endswith(VIDEO)
|
||||
can_flat = bool(video and cpu_render and not opts.get("gpu"))
|
||||
can_flat = bool(video and cpu_render and not opts.get("gpu") and opts.get("nv") != "1")
|
||||
# what each frame draws, as a key (farm_keys.py): read here with nothing drawn, when this raea has --keys
|
||||
keyed, keys_s = farm_keys.read(rest, work, run, cpu_env, f"/tmp/{id}-keys.json") if video and opts.get("keys") else (None, 0)
|
||||
|
||||
@@ -409,8 +409,9 @@ def raea_render(args, opts, work, log, render, cpu_env, run, reload=lambda: None
|
||||
gpu_render, gpu_kind = render, kind
|
||||
# a piece with 3D in it keeps its GPU, and its runs use the GPU's encoder and decoder too (CR34): on a 2D piece NVENC
|
||||
# bought nothing (300 frames: 210 s against libx264's 215 s, 11% more bytes), the page and the clips are the work
|
||||
nv = bool((p.get("manifest") or {}).get("has3d"))
|
||||
flat = bool(video and cpu_render and not opts.get("gpu") and (p.get("manifest") or {}).get("has3d") is False)
|
||||
# (opts nv "1" or "0" says so for the job, and "1" keeps it on GPUs: to measure what NVENC and NVDEC buy a cut)
|
||||
nv = opts.get("nv") == "1" or (opts.get("nv") != "0" and bool((p.get("manifest") or {}).get("has3d")))
|
||||
flat = bool(video and cpu_render and not opts.get("gpu") and opts.get("nv") != "1" and (p.get("manifest") or {}).get("has3d") is False)
|
||||
r0 = None
|
||||
# a flat video whose keys said so goes out at once: no timed first run (FLAT_PART)
|
||||
quick = bool(flat and p.get("keys"))
|
||||
|
||||
@@ -201,7 +201,7 @@ function hashes(file: string) {
|
||||
* farm's cache and named in the job's manifest with no href, so a render's tar holds the code and not the footage
|
||||
* (StreetTalk's 1.9 GB of interviews went in every render's tar, even one frame's). null when the farm has no cache.
|
||||
* `skip`: the tar's excludes. Links are left to the tar, as before. */
|
||||
export async function farmInputs(root: string, farm: FarmBlobs, skip: (p: string) => boolean = () => false, said: (s: string) => void = () => {}, store = path.join(os.homedir(), ".cache", "raea-offload", "hashes.json"), instead: Map<string, string> = new Map()): Promise<{ media: Media[]; sent: number } | null> {
|
||||
export async function farmInputs(root: string, farm: FarmBlobs, skip: (p: string) => boolean = () => false, said: (s: string) => void = () => {}, store = path.join(os.homedir(), ".cache", "raea-offload", "hashes.json"), instead: Map<string, string> = new Map()): Promise<{ media: Media[]; sent: number; links: boolean } | null> {
|
||||
const found: { path: string; abs: string; id: string; size: number; mtime: number }[] = []
|
||||
const walk = (dir: string) => {
|
||||
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
||||
|
||||
@@ -36,12 +36,12 @@ function local(args: string[], why?: string, root?: string): never {
|
||||
if (why) say(`${why}, so this runs here, on the CPU`)
|
||||
// here every take is its light copy: the record says so, as the farm's would (CL20)
|
||||
const lit = lightCopies(root ?? process.cwd())
|
||||
if (lit.size) say(`NO ORIGINAL: a render here reads footage's light copies, so it's a draft that's never shown or published`)
|
||||
if (lit.length) say(`NO ORIGINAL: a render here reads footage's light copies, so it's a draft that's never shown or published`)
|
||||
const r = spawnSync(REAL, args, { stdio: "inherit" })
|
||||
const oi = args.indexOf("-o")
|
||||
const mi = args.indexOf("--manifest")
|
||||
const out = oi >= 0 ? path.resolve(process.cwd(), args[oi + 1] ?? "") : ""
|
||||
if (lit.size && !r.status && out && existsSync(out)) keep(out, mi >= 0 ? path.resolve(process.cwd(), args[mi + 1] ?? "") : null, { read: [], light: [...lit].sort() })
|
||||
if (lit.length && !r.status && out && existsSync(out)) keep(out, mi >= 0 ? path.resolve(process.cwd(), args[mi + 1] ?? "") : null, { read: [], light: [...lit].sort() })
|
||||
process.exit(r.status ?? 1)
|
||||
}
|
||||
|
||||
@@ -181,9 +181,10 @@ async function main() {
|
||||
if (viaFarm && cached.length) say(`${cached.length} media files (${mb(cached)} MB) go by hash from the farm's cache${viaFarm.sent ? `, ${(viaFarm.sent / 1e6).toFixed(1)} MB of it sent now` : ""}`)
|
||||
else if (cached.length) say(`${cached.length} media files (${mb(cached)} MB) go by hash: the farm fetches them from R2`)
|
||||
else if (typeof lfs === "string" && existsSync(path.join(p.root, ".lfsconfig"))) say(`media goes in the tar: ${lfs}`)
|
||||
// a render farm's choices (deploy/modal/farm.py): RAEA_CLOUD_GPUS, RAEA_CLOUD_GPU_KIND, RAEA_CLOUD_MAX_USD
|
||||
// a render farm's choices (deploy/modal/farm.py): RAEA_CLOUD_GPUS, RAEA_CLOUD_GPU_KIND (the card: it went as "gpu",
|
||||
// which the client never read, so a named card never reached the farm), RAEA_CLOUD_MAX_USD, RAEA_CLOUD_NV (1 or 0)
|
||||
const n = (v?: string) => (v ? Number(v) : undefined)
|
||||
const farm = { gpus: n(process.env.RAEA_CLOUD_GPUS), cpus: n(process.env.RAEA_CLOUD_CPUS), kept: process.env.RAEA_CLOUD_KEPT === "0" ? false : undefined, gpu: process.env.RAEA_CLOUD_GPU_KIND, maxUsd: n(process.env.RAEA_CLOUD_MAX_USD), media: typeof lfs !== "string" }
|
||||
const farm = { gpus: n(process.env.RAEA_CLOUD_GPUS), cpus: n(process.env.RAEA_CLOUD_CPUS), kept: process.env.RAEA_CLOUD_KEPT === "0" ? false : undefined, card: process.env.RAEA_CLOUD_GPU_KIND || undefined, maxUsd: n(process.env.RAEA_CLOUD_MAX_USD), nv: process.env.RAEA_CLOUD_NV === "1" ? true : process.env.RAEA_CLOUD_NV === "0" ? false : undefined, media: typeof lfs !== "string" }
|
||||
let finish: (() => Promise<number>) | undefined
|
||||
const media = typeof lfs === "string" ? undefined : async (made: Parameters<typeof outputs>[2]) => {
|
||||
const o = await outputs(p.root, lfs, made)
|
||||
|
||||
@@ -39,6 +39,9 @@ export interface Farm {
|
||||
kept?: boolean
|
||||
card?: string
|
||||
maxUsd?: number
|
||||
/** NVIDIA's encoder and decoder (RAEA_NV) for every run: true on, false off; unset, only a piece with 3D in it (CR34).
|
||||
* On forces the job onto GPUs */
|
||||
nv?: boolean
|
||||
/** the job's media outputs stay on the farm for `media` to send to R2 (docs/cloud-render.feature CR23) */
|
||||
media?: boolean
|
||||
}
|
||||
@@ -169,6 +172,7 @@ export class RaeaCloud {
|
||||
if (farm.card) q.set("gpu", farm.card)
|
||||
if (farm.maxUsd !== undefined) q.set("max_usd", String(farm.maxUsd))
|
||||
if (farm.media) q.set("media", "1")
|
||||
if (farm.nv !== undefined) q.set("nv", farm.nv ? "1" : "0")
|
||||
const r = await this.fetch(`/v1/jobs?${q}`, { method: "POST", body: new Blob([folder as Uint8Array<ArrayBuffer>]), headers: { "content-type": "application/octet-stream" }, signal })
|
||||
return ((await r.json()) as { id: string }).id
|
||||
}
|
||||
|
||||
@@ -263,6 +263,14 @@ g = Flat(root, name="T4")
|
||||
assert fp.raea_render(["render", "a.tsx", "-o", "out/a.mp4"], {"id": "jn", "gpus": 2, "cpus": 0}, os.path.join(root, "jobs", "jn", "work"), log, g, {}, run) == 0, lines
|
||||
assert g.nv and not any(g.nv), g.nv
|
||||
ok("a piece with 3D draws on GPUs with NVENC and NVDEC asked for; a 2D piece kept on GPUs doesn't ask")
|
||||
# the job says so (opts nv): "1" puts a 2D piece on GPUs with them, "0" keeps a 3D piece's GPU without them
|
||||
g, c = Flat(root, name="T4"), Flat(root)
|
||||
assert fp.raea_render(["render", "a.tsx", "-o", "out/a.mp4"], {"id": "jn", "gpus": 2, "cpus": 8, "nv": "1"}, os.path.join(root, "jobs", "jn", "work"), log, g, {}, run, cpu_render=c) == 0, lines
|
||||
assert not c.calls and g.nv and all(g.nv), (c.calls, g.nv)
|
||||
g, c = Flat(root, name="T4", has3d=True), Flat(root)
|
||||
assert fp.raea_render(["render", "a.tsx", "-o", "out/a.mp4"], {"id": "jn", "gpus": 2, "cpus": 8, "nv": "0"}, os.path.join(root, "jobs", "jn", "work"), log, g, {}, run, cpu_render=c) == 0, lines
|
||||
assert not c.calls and g.nv and not any(g.nv), (c.calls, g.nv)
|
||||
ok("a job's nv=1 draws a 2D piece on GPUs with NVENC and NVDEC; nv=0 keeps a 3D piece's GPU without them")
|
||||
|
||||
# the join keeps every frame of runs that have B-frames, with the piece's sound (11-30: -shortest ended the joined
|
||||
# video 2 frames early, 892 of an 894-frame ad)
|
||||
|
||||
Reference in new issue
Block a user