Compare commits

..
Author SHA1 Message Date
shinyobjectz 0a8379c123 A render sends the farm only the video and audio its source names
12-03: every StreetTalk run's first render, a few stills included, hashed and uploaded all of footage/ and
footage/originals/ (36-51 takes and several GB of full-size originals) to the farm's cache one file at a time, and
Elfster's stills render ran past its 5-minute step limit. Video and audio that no source file names, by path, file
name or stem with its folder, now stays on the box, out of the tar and the cache (media.ts unusedMedia); when none is
named, all of it goes, as before, and RAEA_CLOUD_GPU_ALL_MEDIA=1 sends it all regardless. The cache's uploads run four
at a time. Test: node sdk/cloud/test/unused-media.ts
2026-12-03 22:20:01 -08:00
11 changed files with 102 additions and 178 deletions

No files matched your search

+2 -5
View File
@@ -43,9 +43,7 @@ pub fn rendered(args: &[String]) -> i32 {
let excused: Vec<Despite> = through.iter().map(|(c, w)| Despite { check: c.clone(), why: w.clone() }).collect();
let out = raea_runtime_bundle::flag(args, "-o").or_else(|| raea_runtime_bundle::flag(args, "--review")).map(PathBuf::from);
// the manifest every render writes beside its output (DR2), or where --manifest put it
// a plan's manifest is its -o (render --plan)
let plan = args.iter().any(|a| a == "--plan");
let manifest = if plan { out.clone() } else { raea_runtime_bundle::flag(args, "--manifest").map(PathBuf::from).or_else(|| Some(raea_runtime_world::manifest_for(out.as_deref()?, std::path::Path::new(args.get(1)?)))) };
let manifest = raea_runtime_bundle::flag(args, "--manifest").map(PathBuf::from).or_else(|| Some(raea_runtime_world::manifest_for(out.as_deref()?, std::path::Path::new(args.get(1)?))));
if let Some(m) = manifest {
if let Some(mut v) = std::fs::read(&m).ok().and_then(|b| serde_json::from_slice::<Value>(&b).ok()) {
// a video's text, held to the check's text rules as it finishes, a check's round sooner
@@ -64,8 +62,7 @@ pub fn rendered(args: &[String]) -> i32 {
}
}
// a render that is part of another (a review's tiles, a quick check's stills) leaves the entry to that one
// and a plan, which drew nothing, isn't a render to keep
let file = args.get(1).filter(|a| !plan && !a.starts_with('-') && std::env::var("RAEA_RECORD").as_deref() != Ok("off")).map(PathBuf::from);
let file = args.get(1).filter(|a| !a.starts_with('-') && std::env::var("RAEA_RECORD").as_deref() != Ok("off")).map(PathBuf::from);
if let Some(e) = file.and_then(|f| record::keep("raea render", &f, out.as_deref(), &found, excused, &raea_io_trace::utc(SystemTime::now()).1)) {
println!("raea render: kept in the project's record as {} (raea findings reads it)", e.id);
}
-11
View File
@@ -19,7 +19,6 @@ raea render piece.tsx --quality master -o final.mp4 # constant quality for
raea render scene.tsx --review review/ # a 3D scene from six fixed cameras, in colour and clay
raea render piece.tsx -o piece.wav # the sound alone, no frames drawn
raea render piece.tsx -o piece.mp4 --audio piece.wav # the video, and its sound beside it from the same pass
raea render piece.tsx --plan -o piece.plan.json # what every frame shows and plays, nothing drawn
```
What `-o` names decides what you get: a name ending in `.mp4` is a video, `.png` is one frame, `.wav` is the sound
@@ -42,14 +41,6 @@ frames), or where `--manifest` says. It holds what each frame showed as laid out
size, each video's source and time, each picture's box), the sounds heard and what the render found. `raea check`
reads it, and so does [`raea world`](world.md), which measures the output against it when a check asks.
`--plan` writes that manifest without drawing: every frame is stepped through React and laid out, and its sounds are
gathered, but no video frame is decoded, nothing is painted and nothing is encoded, so a 30-second cut is planned in
seconds where its render takes minutes. `-o` names the JSON file. It has a frame entry for every frame (each video's
source, time, box and fit, each text's words, box and size), the sounds heard (each clip's source, in point and
frames) and `"plan": true`; what only drawing finds (exposure, 3D clipping, layers) is left out. `raea goal check --at
edit --manifest PLAN.json` holds a cut to the rules a plan can answer (text in a UI zone, a cut inside a word, text over
a face) before any render.
A render checks what it draws: 3D parts passing into each other (the clipping check), how its 3D is staged (3D type
too small or turned to read, page type over a part, parts that snap, a camera that lurches, frames with almost nothing
on screen; `raea scene stage` runs these without drawing, all but the page's) and its pictures' exposure (clipping to
@@ -70,7 +61,6 @@ the reason in the manifest. A render of a file in a raea project also keeps its
```sh
raea render EDIT.tsx -o OUT.mp4|OUT.png|OUT.wav|DIR [--audio OUT.wav] [--frame N | --at A,B] [--composition ID] [--w W] [--h H] [--fps FPS] [--frames N] [--words W.json] [--perception P.json] [--input I.json|inputs.rrl] [--props JSON|P.json] [--scale S] [--hold FRAME[:FRAMES]] [--manifest render.json] [--layers] [--stage WxH] [--10bit] [--aov] [--alpha [--alpha-codec prores|hevc|rle|png]] [--kbps N | --quality draft|high|master|0..1] [--clay] [--despite CHECK WHY] (also: --lite --comps)
raea render EDIT.tsx --plan -o PLAN.json [--composition ID] [--props JSON|P.json] [--words W.json] [--perception P.json] (every frame through React and layout and its sounds gathered, nothing decoded, drawn or encoded: the render manifest with "plan": true, in seconds, for raea goal check --at edit)
raea render EDIT.tsx --review DIR [--frame N] (fixed cameras hero, front, right, top, iso, low in colour and clay: DIR/colour.png, clay.png, review.json)
raea render PAGE.html -o OUT.mp4|OUT.png|DIR [--at A,B] [--alpha] (an HTML composition)
raea render --bundle NAME.comp.js -o OUT.png|DIR [--dir DIR] [--frame N] (a bundle from raea bundle, as render_bundle draws it)
@@ -105,7 +95,6 @@ Headless: it needs nothing running and opens no window. Takes up to 1 argument b
| `--lite` | – | Draw with raea's live view runtime instead of React, as a live game does. Used by the app when it opens a game. |
| `--manifest` | `render.json` | Write the render's manifest to this file instead of beside the output: the composition's length in frames (`length`, whichever frames were rendered), every frame's element boxes as drawn, what the render found and the sounds heard, which `raea check` and `raea world` read. |
| `--perception` | `P.json` | The perception the composition's Clock reads (faces, boxes, one for every frame or by frame), when it isn't the `perception.json` beside it. |
| `--plan` | – | Write the render manifest of every frame to `-o PLAN.json` without drawing: React and layout run for each frame and its sounds are gathered, but no video is decoded, nothing painted and nothing encoded. The file has `"plan": true`; `raea goal check --at edit --manifest PLAN.json` reads it. |
| `--props` | `JSON\|P.json` | Input props, as a JSON object or a file holding one. `getInputProps()` returns them, and they go over the composition's `defaultProps` before `calculateMetadata` runs. |
| `--quality` | `draft\|high\|master\|0..1` | Constant-quality encoding: `draft` for previews, `high` for most deliveries, `master` for type and hard edges, or a number from 0 to 1. On Windows and Linux (OpenH264) it scales the bitrate instead, and once a frame fits at OpenH264's finest quantiser (12), a higher setting writes the same file. |
| `--review` | `DIR` | Render a 3D scene from six fixed cameras (hero, front, right, top, iso, low), in colour and in clay, to `DIR/colour.png`, `DIR/clay.png` and `DIR/review.json`. |
+1 -1
View File
@@ -384,7 +384,7 @@ pub fn run(args: &[String]) -> R<String> {
}
if args.first().map(String::as_str) != Some("render") || args.len() < 2 {
return Err(format!(
"raea render EDIT.tsx -o OUT.mp4|OUT.png|OUT.wav|DIR [--audio OUT.wav] [--frame N | --at A,B] [--composition ID] [--w W] [--h H] [--fps FPS] [--frames N] [--words W.json] [--perception P.json] [--input I.json|inputs.rrl] [--props JSON|P.json] [--scale S] [--hold FRAME[:FRAMES]] [--manifest render.json] [--keys keys.json] [--layers] [--stage WxH] [--10bit] [--aov] [--alpha [--alpha-codec prores|hevc|rle|png]] [--kbps N | --quality draft|high|master|0..1] [--clay] [--despite CHECK WHY] (also: --lite --comps)\n raea render EDIT.tsx --plan -o PLAN.json [--composition ID] [--props JSON|P.json] [--words W.json] [--perception P.json] (every frame through React and layout and its sounds gathered, nothing decoded, drawn or encoded: the render manifest with \"plan\": true, in seconds, for raea goal check --at edit)\n raea render EDIT.tsx --review DIR [--frame N] (fixed cameras hero, front, right, top, iso, low in colour and clay: DIR/colour.png, clay.png, review.json)\n raea render PAGE.html -o OUT.mp4|OUT.png|DIR [--at A,B] [--alpha] (an HTML composition)\n raea render --bundle NAME.comp.js -o OUT.png|DIR [--dir DIR] [--frame N] (a bundle from raea bundle, as render_bundle draws it)
"raea render EDIT.tsx -o OUT.mp4|OUT.png|OUT.wav|DIR [--audio OUT.wav] [--frame N | --at A,B] [--composition ID] [--w W] [--h H] [--fps FPS] [--frames N] [--words W.json] [--perception P.json] [--input I.json|inputs.rrl] [--props JSON|P.json] [--scale S] [--hold FRAME[:FRAMES]] [--manifest render.json] [--keys keys.json] [--layers] [--stage WxH] [--10bit] [--aov] [--alpha [--alpha-codec prores|hevc|rle|png]] [--kbps N | --quality draft|high|master|0..1] [--clay] [--despite CHECK WHY] (also: --lite --comps)\n raea render EDIT.tsx --review DIR [--frame N] (fixed cameras hero, front, right, top, iso, low in colour and clay: DIR/colour.png, clay.png, review.json)\n raea render PAGE.html -o OUT.mp4|OUT.png|DIR [--at A,B] [--alpha] (an HTML composition)\n raea render --bundle NAME.comp.js -o OUT.png|DIR [--dir DIR] [--frame N] (a bundle from raea bundle, as render_bundle draws it)
raea media probe|still|sheet|audio|loudness|motion|cuts|freezes|proxy|share|lod|trim|concat FILE ... | ffmpeg ARGS | ffprobe ARGS (media work, native: media help)
raea bundle EDIT.tsx --composition-bundle -o OUT.js [--portable DIR] (a composition for render_bundle, on the Mac or the iPhone)\n raea add PKG[@RANGE]... [--dev] | remove NAME... | install [--offline] [--in DIR] (npm packages for the project: raea.lock, node_modules)\n {} (foley, local)\n {} (an instrument's notes, local)\n raea setup-audio [--check] [sao|tokensynth] (install or check the local audio models)\n {} (the song's energy map: beats, sections, builds, drops, stops, hits, cuts per bar; also: --backend NAME)\n raea make sounds [WORDS] | sounds get PACK/INSTRUMENT [--notes ..|--all] [-o DIR] (open sample libraries for a Sampler)\n {} (the clip's camera solved, for <Matchmove>)",
tools::sound::SAO_USAGE, tools::sound::TOKENSYNTH_USAGE, tools::song::USAGE, motion::track::USAGE
-1
View File
@@ -59,7 +59,6 @@ fn a_verb_refuses_what_it_doesnt_take() {
&["render", "e.tsx", "-o", "o.mp4", "--frame", "20", "--input", "i.json", "--manifest", "m.json", "--stage", "1080x1920", "--words", "w.json"][..],
&["render", "e.tsx", "-o", "d", "--at", "0,30", "--composition", "Main", "--w", "1080", "--h", "1920", "--fps", "30", "--frames", "90", "--lite"],
&["render", "e.tsx", "-o", "o.mp4", "--kbps", "-6"],
&["render", "edit.tsx", "--composition", "cut-a", "--plan", "-o", "out/cuts/cut-a.plan.json"],
&["render", "--bundle", "a.comp.js", "-o", "o.png", "--dir", "d", "--frame", "3"],
&["play", "g.tsx", "--input-script", "k.json", "--input-log", "l.json", "--offscreen", "--seconds", "end", "--size", "540x960", "--snapshot", "1.5", "a.png", "--seek", "30", "b.png", "--json", "p.json"],
&["play", "g.tsx", "--input", "--baked", "--scrub", "8", "--autoplay", "--no-vsync", "--master", "--3d"],
+4 -16
View File
@@ -33,8 +33,6 @@ mod bevy_frame;
use bevy_frame::*;
mod keys;
mod pages;
mod plan;
pub use plan::plan_refused;
use pages::*;
mod program;
use program::*;
@@ -70,30 +68,20 @@ pub(crate) struct Sound {
/// `render --keys PATH`: each frame's key written there and nothing drawn (keys.rs).
pub(crate) static KEYS: std::sync::Mutex<Option<PathBuf>> = std::sync::Mutex::new(None);
/// `render --plan -o PLAN.json`: every frame stepped through React and laid out, its sounds gathered, nothing decoded,
/// drawn or encoded; the render manifest written to MANIFEST with "plan": true (plan.rs).
pub(crate) static PLAN: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
/// `render --manifest PATH` (the CLI's; render_bundle keeps its signature for the iPhone): where render.json goes.
static MANIFEST: std::sync::Mutex<Option<PathBuf>> = std::sync::Mutex::new(None);
/// The manifest, its folder made first (2D stills write it before their frames): the composition's length in frames
/// (whatever was rendered of it; raea check --quick samples by it, #86), boxes as drawn, findings, sounds, and whether
/// it drew 3D (an export in layers draws the 3D in the layer under the page, docs/layers.feature LA2a).
fn write_manifest(cx: &mut Ctx, size: (u32, u32, f64, i64), found: Vec<raea_core_facts::Finding>, heard: impl FnOnce(&Ctx) -> Value) -> R<()> {
write_manifest_with(cx, size, found, heard, |_| {})
}
/// write_manifest, with `more` given the document before it's written (a plan's own fields, plan.rs).
fn write_manifest_with(cx: &mut Ctx, (w, h, fps, length): (u32, u32, f64, i64), found: Vec<raea_core_facts::Finding>, heard: impl FnOnce(&Ctx) -> Value, more: impl FnOnce(&mut Value)) -> R<()> {
fn write_manifest(cx: &mut Ctx, (w, h, fps, length): (u32, u32, f64, i64), found: Vec<raea_core_facts::Finding>, heard: impl FnOnce(&Ctx) -> Value) -> R<()> {
let (Some(path), Some(frames)) = (MANIFEST.lock().unwrap().clone(), cx.manifest.take()) else { return Ok(()) };
path.parent().filter(|d| !d.as_os_str().is_empty()).map_or(Ok(()), std::fs::create_dir_all).map_err(|e| format!("{}: {e}", path.display()))?;
path.parent().map_or(Ok(()), std::fs::create_dir_all).map_err(|e| format!("{}: {e}", path.display()))?;
let mut v = json!({"width": w, "height": h, "fps": fps, "length": length, "frames": frames, "findings": raea_core_facts::finding::ranked(found), "sounds": heard(cx), "not_applied": not_applied::seen(), "layers": raea_sys_layers::finish(fps), "has3d": cx.scene3d.is_some() || cx.live3d.is_some()});
// the parts SG9 needs (scene.rs's SEEN: stills' parts on screen, a longer render's remounts), and --props and --scale
for given in [scene::SEEN.lock().unwrap().take(), GIVEN.lock().unwrap().clone()] {
v.as_object_mut().into_iter().zip(given.and_then(|m| m.as_object().cloned())).for_each(|(m, given)| m.extend(given));
for more in [scene::SEEN.lock().unwrap().take(), GIVEN.lock().unwrap().clone()] {
v.as_object_mut().into_iter().zip(more.and_then(|m| m.as_object().cloned())).for_each(|(m, more)| m.extend(more));
}
more(&mut v);
std::fs::write(&path, v.to_string()).map_err(|e| format!("{}: {e}", path.display()))
}
-119
View File
@@ -1,119 +0,0 @@
//! `render --plan -o PLAN.json`: what a render would show and play, frame by frame, with nothing drawn. React is stepped
//! through every frame as a render steps it, the page made to match each frame's tree and laid out (styles, fonts,
//! layout: Blitz's main world, never its render world), and each frame's sounds gathered as a render gathers them, but
//! no video's frame is decoded (the page syncs as `render --keys` does), nothing is painted and nothing is encoded.
//!
//! PLAN.json is the render manifest (`render --manifest`): width, height, fps, length, a frame entry for every frame of
//! the composition (its videos' sources, times and boxes, its text's words, boxes and sizes, its pictures), the sounds
//! heard (each clip's source, in point and frames), with "plan": true and whether a frame holds 3D. What a render's
//! manifest says that only drawing finds isn't in it: its exposure, its 3D's clipping and its layers (null).
//!
//! It is the edit moment's input (`raea goal check --at edit --manifest PLAN.json`): a cut's text in a UI zone, a
//! clip's in point inside a word, a caption over a face are known from it before any frame is drawn. A 32 s cut (952
//! frames at 1080x1920, 5 clips of one interview, a caption a line) is planned in 4 s on a raea cloud box's 8 CPUs (8 s
//! with nothing cached), where its render took 130 s on the same box and 152 s on the farm's 32 CPU containers; the
//! plan's frames and sounds are the render's own manifest's, box for box (12-04, on three projects' cuts).
use super::*;
/// Why `--plan` can't be taken with the other flags in `args`, or None. A plan is every frame of the composition, has
/// no picture, and is written where -o says.
pub fn plan_refused(args: &[String]) -> Option<String> {
if !args.iter().any(|a| a == "--plan") {
return None;
}
for f in ["--frame", "--at", "--keys", "--review", "--hold", "--aov", "--alpha", "--layers", "--audio", "--bundle"] {
if args.iter().any(|a| a == f) {
return Some(format!("--plan lays out every frame of the composition and draws none, so it doesn't take {f}"));
}
}
let out = flag(args, "-o");
if !out.as_deref().is_some_and(|o| o.to_lowercase().ends_with(".json")) {
return Some("--plan writes the render manifest of every frame: -o PLAN.json".into());
}
if flag(args, "--manifest").is_some_and(|m| Some(&m) != out.as_ref()) {
return Some("--plan writes its manifest where -o says (PLAN.json): leave --manifest out".into());
}
None
}
pub(crate) fn write(app: &mut App, page: &mut raea_runtime_page::BevyPage, cx: &mut Ctx, (w, h, fps, total): (u32, u32, f64, i64)) -> R<String> {
let t0 = std::time::Instant::now();
// a keyed sync places no video's frame: nothing decoded (bevy_page.rs)
page.keyed = Some(0);
let (mut frames, mut tones) = (Vec::with_capacity(total.max(0) as usize), Vec::new());
let mut has3d = false;
// RAEA_TIMES: where the plan's time goes, totals in ms
let times = raea_io_trace::stat("RAEA_TIMES");
let (mut t_react, mut t_sync, mut t_lay) = (0f64, 0f64, 0f64);
for f in 0..total {
let a = std::time::Instant::now();
step_react(app, page, cx, (f, fps), true)?;
let b = std::time::Instant::now();
page.at_frame(f, fps);
bevy_page_sync(app.world_mut(), page, cx)?;
let c = std::time::Instant::now();
page.lay_out();
if let Some(m) = cx.manifest.as_mut() {
m.push(page.manifest_frame(f));
}
has3d |= !cx.scene.is_empty();
tones.push(raea_runtime_sound::tone_at(app.world_mut(), f, fps, cx.dir, media_path, true));
frames.push((f, Frame { mix: cx.mix, page: None, sounds: cx.sounds.clone(), scene: Vec::new(), clear: None, same: false, screens: Vec::new() }));
if times {
t_react += (b - a).as_secs_f64() * 1e3;
t_sync += (c - b).as_secs_f64() * 1e3;
t_lay += c.elapsed().as_secs_f64() * 1e3;
}
}
if times {
eprintln!("raea times: react {t_react:.0} ms, page synced {t_sync:.0} ms, laid out and read {t_lay:.0} ms over {total} frames");
}
let to = MANIFEST.lock().unwrap().clone().ok_or("--plan: no -o PLAN.json")?;
write_manifest_with(cx, (w, h, fps, total), Vec::new(), |cx| heard(&frames, &tones, cx, fps), |v| mark(v, has3d))?;
Ok(format!("APPLIED {total} frames planned in {} (laid out with nothing drawn, {:.1} s)", to.display(), t0.elapsed().as_secs_f64()))
}
/// A manifest made a plan: "plan": true, and whether any frame holds 3D (the plan draws none, so the manifest's own
/// "has3d", the drawn 3D's, would say no). Its other keys stay as a render's manifest has them.
fn mark(v: &mut Value, has3d: bool) {
if let Some(o) = v.as_object_mut() {
o.insert("plan".into(), json!(true));
o.insert("has3d".into(), json!(has3d));
}
}
#[cfg(test)]
mod tests {
use super::*;
fn a(s: &[&str]) -> Vec<String> {
s.iter().map(|a| a.to_string()).collect()
}
#[test]
fn a_plan_is_every_frame_written_where_o_says() {
assert_eq!(plan_refused(&a(&["render", "e.tsx", "--composition", "c", "--plan", "-o", "out/c.plan.json"])), None);
assert_eq!(plan_refused(&a(&["render", "e.tsx", "--plan", "-o", "p.json", "--manifest", "p.json", "--props", "{}"])), None);
// not a plan: nothing to refuse
assert_eq!(plan_refused(&a(&["render", "e.tsx", "--at", "3", "-o", "d/"])), None);
assert!(plan_refused(&a(&["render", "e.tsx", "--plan", "-o", "c.mp4"])).unwrap().contains("-o PLAN.json"));
assert!(plan_refused(&a(&["render", "e.tsx", "--plan"])).unwrap().contains("-o PLAN.json"));
assert!(plan_refused(&a(&["render", "e.tsx", "--plan", "--at", "0,30", "-o", "p.json"])).unwrap().contains("--at"));
assert!(plan_refused(&a(&["render", "e.tsx", "--plan", "--keys", "k.json", "-o", "p.json"])).unwrap().contains("--keys"));
assert!(plan_refused(&a(&["render", "e.tsx", "--plan", "-o", "p.json", "--manifest", "m.json"])).unwrap().contains("--manifest"));
}
#[test]
fn a_plan_says_so_in_the_manifests_own_shape() {
let mut v = json!({"width": 1080, "height": 1920, "fps": 30.0, "length": 2, "frames": [{"frame": 0}, {"frame": 1}], "has3d": false, "layers": null, "sounds": {"clips": []}});
mark(&mut v, true);
assert_eq!(v["plan"], true);
assert_eq!(v["has3d"], true);
// every key a render's manifest has stays, so a reader of one reads the other
for k in ["width", "height", "fps", "length", "frames", "layers", "sounds"] {
assert!(v.get(k).is_some(), "{k}");
}
assert_eq!(v["frames"].as_array().unwrap().len(), 2);
}
}
-15
View File
@@ -28,9 +28,6 @@ pub fn render(args: &[String]) -> R<String> {
if args.iter().any(|a| a == "--clay") {
raea_runtime_scene3d::clay::CLAY.store(true, std::sync::atomic::Ordering::Relaxed);
}
if let Some(why) = plan_refused(args) {
return Err(why);
}
let tsx = dunce::canonicalize(&PathBuf::from(&args[1])).map_err(|e| format!("{}: {e}", args[1]))?;
let out = PathBuf::from(flag(args, "-o").ok_or("-o OUT.mp4|OUT.png|DIR")?);
let dir = tsx.parent().unwrap().to_path_buf();
@@ -68,15 +65,6 @@ pub fn render(args: &[String]) -> R<String> {
(_, Some(at)) => Some(at.split(',').map(|f| f.trim().parse::<i64>().map_err(|_| "--at takes frame numbers".to_string())).collect::<R<_>>()?),
_ => None,
};
// --plan: every frame laid out and its sounds gathered, nothing decoded, drawn or encoded; the manifest at -o (plan.rs)
if args.iter().any(|a| a == "--plan") {
*MANIFEST.lock().unwrap() = Some(out.clone());
PLAN.store(true, std::sync::atomic::Ordering::Relaxed);
let said = render_bundle_with(&js, &dir, &out, None, false, None, false);
PLAN.store(false, std::sync::atomic::Ordering::Relaxed);
let _ = std::fs::remove_file(&js);
return said;
}
if let Some(k) = flag(args, "--keys") {
*KEYS.lock().unwrap() = Some(PathBuf::from(k));
let said = render_bundle_with(&js, &dir, &out, None, false, None, false);
@@ -318,9 +306,6 @@ pub(crate) fn render_bundle_with(js: &Path, dir: &Path, out: &Path, wanted: Opti
if let Some(to) = KEYS.lock().unwrap().take() {
return crate::keys::write(&to, &mut app, &mut page, &mut cx, (w, h, fps, total));
}
if PLAN.load(std::sync::atomic::Ordering::Relaxed) {
return crate::plan::write(&mut app, &mut page, &mut cx, (w, h, fps, total));
}
if fed {
if let Some(p) = scene {
aov_on(raea_render::engine::Engine::open_in(&mut cx.scene3d, &p, dir)?);
-4
View File
@@ -2,10 +2,6 @@
# raea in raea cloud's image (docs/cloud.feature CL15): with RAEA_CLOUD_GPU_URL set, `raea render ...` (each command in
# RAEA_CLOUD_GPU_COMMANDS) goes to that GPU worker (server/offload.ts); everything else, and everything when it isn't
# set, is raea itself. The server, the agents and their shells all reach raea through this one.
# A render's plan (`raea render EDIT.tsx --plan -o PLAN.json`) draws nothing: it runs here, on the box's CPU, in seconds.
for a in "$@"; do
[ "$a" = "--plan" ] && exec /opt/raea/bin/raea "$@"
done
if [ -n "${RAEA_CLOUD_GPU_URL:-}" ] && [ -n "${1:-}" ]; then
case " ${RAEA_CLOUD_GPU_COMMANDS:-render} " in
*" $1 "*) exec node /opt/raea-cloud/server/offload.ts "$@" ;;
+44 -3
View File
@@ -225,13 +225,54 @@ export async function farmInputs(root: string, farm: FarmBlobs, skip: (p: string
let sent = 0
const todo = media.filter((m, i) => !have.has(m.oid) && media.findIndex((x) => x.oid === m.oid) === i)
if (todo.length) said(`sending ${todo.length} media files (${(todo.reduce((n, m) => n + m.size, 0) / 1e6).toFixed(1)} MB) to the farm's cache, once`)
for (const m of todo) {
await farm.put(m.abs, m.oid, m.size)
sent += m.size
// four at a time: one by one, 50 takes took minutes on a box whose uplink sits mostly idle
let next = 0
const one = async () => {
for (let i = next++; i < todo.length; i = next++) {
await farm.put(todo[i].abs, todo[i].oid, todo[i].size)
sent += todo[i].size
}
}
await Promise.all(Array.from({ length: Math.min(4, todo.length) }, one))
return { media: media.map(({ abs: _, ...m }) => m), sent }
}
/** the project's video and audio that no source file names, which a render doesn't need: neither sent to the farm nor
* packed. 12-03: footage/originals/ (the full-size takes, several GB) went to the farm on the first render of every
* StreetTalk run, a still included, and the render ran past its 5 minutes. A file is named by its path, its file name,
* or its stem with its folder's name ("originals/" + `${id}.mov`). When no source names any, all of it is used, as
* before; RAEA_CLOUD_GPU_ALL_MEDIA=1 sends it all regardless */
export function unusedMedia(root: string, skip: (p: string) => boolean = () => false): string[] {
if (process.env.RAEA_CLOUD_GPU_ALL_MEDIA === "1") return []
const AV = new Set(["mp4", "mov", "m4v", "webm", "mkv", "mxf", "avi", "wav", "mp3", "m4a", "aac", "flac", "ogg"])
const SRC = new Set(["tsx", "ts", "jsx", "js", "mjs", "json", "css"])
// folders of what's made for the agent or by a render, not what a composition reads from (footage/index.json lists
// every take)
const NOT_SOURCE = new Set(["footage", "brief_docs", "review", "out", "node_modules", "previews"])
const av: string[] = []
let text = ""
const walk = (dir: string, source: boolean) => {
for (const e of readdirSync(dir, { withFileTypes: true })) {
const abs = path.join(dir, e.name)
const rel = path.relative(root, abs).split(path.sep).join("/")
if (skip(rel) || e.name === ".git" || e.name.startsWith(".raea-cloud")) continue
const ext = e.name.includes(".") ? e.name.split(".").pop()!.toLowerCase() : ""
if (e.isDirectory()) walk(abs, source && !(dir === root && NOT_SOURCE.has(e.name)))
else if (e.isFile() && AV.has(ext)) av.push(rel)
else if (e.isFile() && source && SRC.has(ext) && statSync(abs).size < 2 << 20) text += readFileSync(abs, "utf8") + "\n"
}
}
walk(root, true)
const named = (rel: string) => {
const name = rel.split("/").pop()!
const stem = name.replace(/\.[^.]+$/, "")
const folder = rel.includes("/") ? rel.split("/").slice(-2, -1)[0] + "/" : ""
return text.includes(rel) || text.includes(name) || (stem.length >= 3 && text.includes(stem) && (!folder || text.includes(folder)))
}
const used = av.filter(named)
return used.length ? av.filter((f) => !used.includes(f)) : []
}
/** tar's exclude-from lines for paths that go by hash: each matched as written (glob characters escaped) */
export const excludes = (media: Media[]) => media.map((m) => "./" + m.path.replace(/[\\*?[\]]/g, (c) => "\\" + c)).join("\n") + "\n"
+11 -3
View File
@@ -21,7 +21,7 @@ import os from "node:os"
import path from "node:path"
import { pathToFileURL } from "node:url"
import { RaeaCloud } from "../src/index.ts"
import { excluded, excludes as mediaExcludes, farmBlobs, farmInputs, inputs, lfsOf, localSources, outputs } from "./media.ts"
import { excluded, excludes as mediaExcludes, farmBlobs, farmInputs, inputs, lfsOf, localSources, outputs, unusedMedia } from "./media.ts"
const REAL = process.env.RAEA_REAL ?? "/opt/raea/bin/raea"
// flags whose value is a path raea writes; the rest of a render's path arguments are read
@@ -111,16 +111,24 @@ async function main() {
const sent = path.join(tmp, "in.tar")
// the media that goes by hash: out of the tar, named in its manifest
const lfs = lfsOf(p.root)
let byHash = typeof lfs === "string" ? [] : await inputs(p.root, lfs, excluded(excludes))
// video and audio no source file names stays here, out of the tar and the farm's cache (media.ts unusedMedia)
const unused = new Set(unusedMedia(p.root, excluded(excludes)))
if (unused.size) say(`${unused.size} video and audio files no source names stay here`)
const skip = (rel: string) => excluded(excludes)(rel) || unused.has(rel)
let byHash = typeof lfs === "string" ? [] : await inputs(p.root, lfs, skip)
// not in raea's LFS: the media goes into the farm's own cache by hash, once, instead of in every render's tar
// (RAEA_CLOUD_GPU_BLOBS=0 puts it back in the tar). A farm without the cache, or one that can't be reached here,
// leaves it in the tar, and the health check below says why the farm can't be reached
let viaFarm: { media: typeof byHash; sent: number } | null = null
if (typeof lfs === "string" && process.env.RAEA_CLOUD_GPU_BLOBS !== "0") {
viaFarm = await farmInputs(p.root, farmBlobs(url, token), excluded(excludes), say).catch((e) => (say(`the farm's media cache: ${(e as Error).message}; the media goes in the tar`), null))
viaFarm = await farmInputs(p.root, farmBlobs(url, token), skip, say).catch((e) => (say(`the farm's media cache: ${(e as Error).message}; the media goes in the tar`), null))
if (viaFarm) byHash = viaFarm.media
}
const extra: string[] = []
if (unused.size) {
writeFileSync(path.join(tmp, "unused-excludes"), mediaExcludes([...unused].map((f) => ({ path: f, oid: "", size: 0 }))))
extra.push("-X", path.join(tmp, "unused-excludes"))
}
if (byHash.length) {
writeFileSync(path.join(tmp, "media-excludes"), mediaExcludes(byHash))
writeFileSync(path.join(tmp, ".raea-cloud-media.json"), JSON.stringify({ objects: byHash }))
+40
View File
@@ -0,0 +1,40 @@
// What a render leaves on the box (server/media.ts unusedMedia): video and audio no source file names. 12-03: every
// StreetTalk run's first render sent footage/originals/ (several GB) to the farm, a still included, and ran past its
// 5 minutes. Run: node test/unused-media.ts (prints ok, or FAIL and exits 1)
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs"
import { tmpdir } from "node:os"
import path from "node:path"
import { unusedMedia } from "../server/media.ts"
const fail = (m: string): never => {
console.error(`FAIL ${m}`)
process.exit(1)
}
const project = (files: Record<string, string>) => {
const root = mkdtempSync(path.join(tmpdir(), "raea-unused-"))
for (const [f, c] of Object.entries(files)) {
mkdirSync(path.dirname(path.join(root, f)), { recursive: true })
writeFileSync(path.join(root, f), c)
}
return root
}
const same = (a: string[], b: string[], what: string) => JSON.stringify([...a].sort()) === JSON.stringify([...b].sort()) || fail(`${what}: ${JSON.stringify([...a].sort())}`)
// a cut on the light copies: the originals and the untouched takes stay; index.json (which lists every take) isn't source
const takes = {
"footage/Angle1-Take1.mp4": "x", "footage/Angle1-Take2.mp4": "x", "footage/Angle2-Take1.mp4": "x",
"footage/originals/Angle1-Take1.mov": "x", "footage/originals/Angle1-Take2.mov": "x", "footage/originals/Angle2-Take1.mov": "x",
"footage/index.json": JSON.stringify(["Angle1-Take1.mp4", "Angle1-Take2.mp4", "Angle2-Take1.mp4"]),
"media/music/bed.mp3": "x",
}
same(unusedMedia(project({ ...takes, "cut_a.tsx": `<Video src="footage/Angle1-Take1.mp4" /><Video src={"footage/" + "Angle1-Take2.mp4"} /><Audio src="media/music/bed.mp3" />` })),
["footage/Angle2-Take1.mp4", "footage/originals/Angle1-Take1.mov", "footage/originals/Angle1-Take2.mov", "footage/originals/Angle2-Take1.mov"], "a cut on the light copies")
// the final render on the originals by id: originals/ named, the stem from data. The take's light copy goes too
// ("footage/" is in "footage/originals/"): a few MB, against the GB of originals that stay
same(unusedMedia(project({ ...takes, "cut_a.tsx": "const src = (id: string) => `footage/originals/${id}.mov`", "cuts.json": JSON.stringify({ shots: ["Angle1-Take1"] }) })),
["footage/Angle1-Take2.mp4", "footage/Angle2-Take1.mp4", "footage/originals/Angle1-Take2.mov", "footage/originals/Angle2-Take1.mov", "media/music/bed.mp3"], "the final render on the originals")
// nothing names any media: all of it is used, as before
same(unusedMedia(project({ ...takes, "cut_a.tsx": "export default () => null" })), [], "no source names any")
console.log("ok")