Compare commits

...
1 Commits
Author SHA1 Message Date
shinyobjectz 43f730837a raea render --plan: every frame's manifest with nothing drawn
`raea render EDIT.tsx --composition ID --plan -o PLAN.json` steps React through every frame, makes the page match each frame's tree and lays it out, and gathers each frame's sounds as a render does. It decodes no video frame, paints nothing and encodes nothing. PLAN.json is the render manifest's own shape (a frame entry for every frame, the sounds heard, findings) with "plan": true, so the edit moment's checks can read a cut before it is rendered.

The plan pass is the --keys loop, plus lay_out and manifest_frame each frame, written through the same write_manifest and heard(). A plan's findings go into PLAN.json, and a plan isn't kept in the project's record as a render. On a raea cloud box a render with --plan runs on the box, not through offload.ts.

Measured on a 952-frame 1080x1920 cut, on a raea cloud box with 8 CPUs: the plan took 4.0 s, or 8.3 s with the page cache dropped. Rendering the same cut took 130 s on the same box and 152 s on the farm. Compared with full renders of the same edits on the same box, every frame's videos, text boxes (0 px apart) and sound clips match. Tested with plan::tests and the CLI's refusal test, run on Modal.
2026-12-04 10:44:40 -08:00
8 changed files with 172 additions and 7 deletions

No files matched your search

+5 -2
View File
@@ -43,7 +43,9 @@ pub fn rendered(args: &[String]) -> i32 {
let excused: Vec<Despite> = through.iter().map(|(c, w)| Despite { check: c.clone(), why: w.clone() }).collect(); 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); 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 // the manifest every render writes beside its output (DR2), or where --manifest put it
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)?)))); // 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)?)))) };
if let Some(m) = manifest { 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()) { 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 // a video's text, held to the check's text rules as it finishes, a check's round sooner
@@ -62,7 +64,8 @@ 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 // a render that is part of another (a review's tiles, a quick check's stills) leaves the entry to that one
let file = args.get(1).filter(|a| !a.starts_with('-') && std::env::var("RAEA_RECORD").as_deref() != Ok("off")).map(PathBuf::from); // 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);
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)) { 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); println!("raea render: kept in the project's record as {} (raea findings reads it)", e.id);
} }
+11
View File
@@ -19,6 +19,7 @@ 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 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.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 -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 What `-o` names decides what you get: a name ending in `.mp4` is a video, `.png` is one frame, `.wav` is the sound
@@ -41,6 +42,14 @@ 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` 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. 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 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 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 on screen; `raea scene stage` runs these without drawing, all but the page's) and its pictures' exposure (clipping to
@@ -61,6 +70,7 @@ the reason in the manifest. A render of a file in a raea project also keeps its
```sh ```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 -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 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 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) raea render --bundle NAME.comp.js -o OUT.png|DIR [--dir DIR] [--frame N] (a bundle from raea bundle, as render_bundle draws it)
@@ -95,6 +105,7 @@ 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. | | `--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. | | `--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. | | `--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. | | `--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. | | `--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`. | | `--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 { if args.first().map(String::as_str) != Some("render") || args.len() < 2 {
return Err(format!( 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 --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 --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 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 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>)", 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 tools::sound::SAO_USAGE, tools::sound::TOKENSYNTH_USAGE, tools::song::USAGE, motion::track::USAGE
+1
View File
@@ -59,6 +59,7 @@ 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", "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", "d", "--at", "0,30", "--composition", "Main", "--w", "1080", "--h", "1920", "--fps", "30", "--frames", "90", "--lite"],
&["render", "e.tsx", "-o", "o.mp4", "--kbps", "-6"], &["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"], &["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-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"], &["play", "g.tsx", "--input", "--baked", "--scrub", "8", "--autoplay", "--no-vsync", "--master", "--3d"],
+16 -4
View File
@@ -33,6 +33,8 @@ mod bevy_frame;
use bevy_frame::*; use bevy_frame::*;
mod keys; mod keys;
mod pages; mod pages;
mod plan;
pub use plan::plan_refused;
use pages::*; use pages::*;
mod program; mod program;
use program::*; use program::*;
@@ -68,20 +70,30 @@ pub(crate) struct Sound {
/// `render --keys PATH`: each frame's key written there and nothing drawn (keys.rs). /// `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); 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. /// `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); 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 /// 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 /// (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). /// 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, (w, h, fps, length): (u32, u32, f64, i64), found: Vec<raea_core_facts::Finding>, heard: impl FnOnce(&Ctx) -> Value) -> R<()> { 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<()> {
let (Some(path), Some(frames)) = (MANIFEST.lock().unwrap().clone(), cx.manifest.take()) else { return Ok(()) }; let (Some(path), Some(frames)) = (MANIFEST.lock().unwrap().clone(), cx.manifest.take()) else { return Ok(()) };
path.parent().map_or(Ok(()), std::fs::create_dir_all).map_err(|e| format!("{}: {e}", path.display()))?; 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()))?;
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()}); 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 // the parts SG9 needs (scene.rs's SEEN: stills' parts on screen, a longer render's remounts), and --props and --scale
for more in [scene::SEEN.lock().unwrap().take(), GIVEN.lock().unwrap().clone()] { for given 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)); v.as_object_mut().into_iter().zip(given.and_then(|m| m.as_object().cloned())).for_each(|(m, given)| m.extend(given));
} }
more(&mut v);
std::fs::write(&path, v.to_string()).map_err(|e| format!("{}: {e}", path.display())) std::fs::write(&path, v.to_string()).map_err(|e| format!("{}: {e}", path.display()))
} }
+119
View File
@@ -0,0 +1,119 @@
//! `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,6 +28,9 @@ pub fn render(args: &[String]) -> R<String> {
if args.iter().any(|a| a == "--clay") { if args.iter().any(|a| a == "--clay") {
raea_runtime_scene3d::clay::CLAY.store(true, std::sync::atomic::Ordering::Relaxed); 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 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 out = PathBuf::from(flag(args, "-o").ok_or("-o OUT.mp4|OUT.png|DIR")?);
let dir = tsx.parent().unwrap().to_path_buf(); let dir = tsx.parent().unwrap().to_path_buf();
@@ -65,6 +68,15 @@ 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<_>>()?), (_, Some(at)) => Some(at.split(',').map(|f| f.trim().parse::<i64>().map_err(|_| "--at takes frame numbers".to_string())).collect::<R<_>>()?),
_ => None, _ => 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") { if let Some(k) = flag(args, "--keys") {
*KEYS.lock().unwrap() = Some(PathBuf::from(k)); *KEYS.lock().unwrap() = Some(PathBuf::from(k));
let said = render_bundle_with(&js, &dir, &out, None, false, None, false); let said = render_bundle_with(&js, &dir, &out, None, false, None, false);
@@ -306,6 +318,9 @@ pub(crate) fn render_bundle_with(js: &Path, dir: &Path, out: &Path, wanted: Opti
if let Some(to) = KEYS.lock().unwrap().take() { if let Some(to) = KEYS.lock().unwrap().take() {
return crate::keys::write(&to, &mut app, &mut page, &mut cx, (w, h, fps, total)); 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 fed {
if let Some(p) = scene { if let Some(p) = scene {
aov_on(raea_render::engine::Engine::open_in(&mut cx.scene3d, &p, dir)?); aov_on(raea_render::engine::Engine::open_in(&mut cx.scene3d, &p, dir)?);
+4
View File
@@ -2,6 +2,10 @@
# raea in raea cloud's image (docs/cloud.feature CL15): with RAEA_CLOUD_GPU_URL set, `raea render ...` (each command in # 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 # 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. # 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 if [ -n "${RAEA_CLOUD_GPU_URL:-}" ] && [ -n "${1:-}" ]; then
case " ${RAEA_CLOUD_GPU_COMMANDS:-render} " in case " ${RAEA_CLOUD_GPU_COMMANDS:-render} " in
*" $1 "*) exec node /opt/raea-cloud/server/offload.ts "$@" ;; *" $1 "*) exec node /opt/raea-cloud/server/offload.ts "$@" ;;