// STAGE-2/REDESIGN-5 OpenMotion full main-tour: composition builder. // // REDESIGN-5 GOAL, per explicit user feedback on the previous build // (full-v10.mp4): that build froze a single still PNG for the entirety of // every mini-app's on-screen window (REDESIGN-4's `layoutAppStage()` // decision, after two live-video attempts intermittently showed a black // frame), paired with a "SIGNED EVENT LOG - LIVE" terminal/monospace panel // (hex hash, `type`/`fields` JSON line, blinking cursor) per app. Both are // gone: // - capture.mjs now records ONE dedicated real clip per mini-app (marked // by tour.mjs's app--start/-end pairs, each extended with a real, // visibly-moving `linger()` - scroll pulses + a real :hover state, never // a frozen frame), so every app's clip IS its own on-screen window - // played back in full, continuously. No hold mechanism, no extracted // still frames, no mediaStart/dwell estimation: the window duration is // just that app's own real captured clip length. // - the per-app side panel is now a single large, bold, SHORT plain- // language headline (app-store-feature-callout style) with an optional // small caption naming the real signed event type - no hex, no JSON, no // monospace/terminal styling anywhere. // // Everything else (data open, chapter cards, assembly two-device clip, // result wall) is unchanged structurally from REDESIGN-3/4 - this build // only touches the per-app stage content and its timing math, which is now // far simpler (sum of real clip durations, not an estimated reading-time / // real-dwell / hold-floor computation). // // REBUILD + RENDER (captured footage in assets/*.mp4 is reused as-is; only // run capture.mjs/captureAssembly.mjs again if the app's UI itself changed): // bun e2e/openmotion/buildComposition.mjs // cd e2e/openmotion && \ // HYPERFRAMES_FFMPEG_PATH=/node_modules/ffmpeg-static/ffmpeg \ // HYPERFRAMES_FFPROBE_PATH=/node_modules/ffprobe-static/bin/linux/x64/ffprobe \ // HYPERFRAMES_BROWSER_PATH=~/.cache/ms-playwright/chromium-1255/chrome-linux64/chrome \ // /home/athapa/openmotion/node_modules/hyperframes/bin/hyperframes.mjs \ // render . -o renders/.mp4 --video-frame-format png import { readFileSync, writeFileSync, mkdirSync, copyFileSync, existsSync } from "node:fs"; import { execFileSync } from "node:child_process"; import { dirname, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import ffmpegStatic from "ffmpeg-static"; import { TITLE_CARDS } from "./tour.mjs"; import { HOLLOW_DEMO_FIXTURE } from "../../src/admin/seedEvents.ts"; const __dirname = dirname(fileURLToPath(import.meta.url)); const OM_DIR = __dirname; const MANIFEST = resolve(OM_DIR, "capture-manifest.json"); const ASSEMBLY_MANIFEST = resolve(OM_DIR, "assembly-manifest.json"); const COMPOSITIONS_DIR = resolve(OM_DIR, "compositions"); const ASSETS_DIR = resolve(OM_DIR, "assets"); const WALL_DIR = resolve(ASSETS_DIR, "wall"); // Real per-mini-app Playwright screenshots captured by the same real-app run // (one still per mini-app). Used only in the closing result wall. const SHOT_SRC = resolve(OM_DIR, "..", "..", ".omo", "evidence", "full-feature-demo"); const FFMPEG_BIN = ffmpegStatic; const CANVAS_W = 1920; const CANVAS_H = 1080; const FPS = 30; const BEZEL = 8; // thin modern device frame around the real screen footage // --- ambient audio (unchanged proven approach) --- // Three sine oscillators C3/E3/G3 amixed 1/0.8/0.7, slow tremolo, baked // fades. Raw track ~-27.9 dB mean; data-volume 0.30 lands the final mix at // ~-38 dB mean (in the proven -37..-40 dB band, max well below 0). const AMBIENT_SRC = "assets/ambient.mp3"; const AMBIENT_VOLUME = 0.3; const esc = (s) => String(s).replace(/&/g, "&").replace(//g, ">"); const r3 = (n) => Number(Number(n).toFixed(3)); // --------------------------------------------------------------------- // Palette: a COLOR JOURNEY. Bold saturated chapter colors punctuate darker // tinted act fields, so the background visibly changes shape over the // runtime instead of one dark blue the whole time. No pure white anywhere // (keeps the luma scan clean - no white-flash ambiguity). // --------------------------------------------------------------------- const BRAND = "#1677FF"; const COLORS = { data: "linear-gradient(150deg,#1a7bff 0%,#0f62d8 55%,#0a46a6 100%)", chapter1: "linear-gradient(150deg,#1657c8 0%,#0c346f 100%)", // azure chapter2: "linear-gradient(150deg,#ffb020 0%,#f58a10 100%)", // amber (dark text) chapter3: "linear-gradient(150deg,#13a085 0%,#0a5f50 100%)", // teal chapterE: "linear-gradient(150deg,#7a52e8 0%,#4b2fb0 100%)", // violet fieldAct1: "radial-gradient(1200px 820px at 70% 30%,#123a6b 0%,#081c3a 60%,#05101f 100%)", // deep ocean fieldAct2: "radial-gradient(1200px 820px at 50% 24%,#1a2330 0%,#0d1117 62%,#06080c 100%)", // charcoal fieldAct3: "radial-gradient(1200px 820px at 30% 30%,#1b2a66 0%,#10163a 60%,#080b22 100%)", // indigo fieldEpi: "radial-gradient(1200px 820px at 50% 28%,#2c1a56 0%,#1a1030 60%,#0d0820 100%)", // plum fieldAssembly: "radial-gradient(900px 640px at 50% 56%,#4a2a86 0%,#241a52 55%,#0d0820 100%)", // plum/indigo blend wall: "linear-gradient(160deg,#1a7bff 0%,#0e55c0 55%,#0a327e 100%)", }; // --------------------------------------------------------------------- // Result-wall tiles: one real captured screenshot per mini-app (13). // --------------------------------------------------------------------- const WALL_TILES = [ { file: "main-03-waterwatch-no-false-alert.png", label: "Water Watch" }, { file: "main-07-fairshare-water.png", label: "Fair Share" }, { file: "main-11-farms-forecast.png", label: "Farms" }, { file: "main-13-housing.png", label: "Housing" }, { file: "main-16-mentor.png", label: "Mentor" }, { file: "main-18-healthpost-triage.png", label: "Health Post" }, { file: "main-20-lightclock-manual-fallback.png", label: "Light Clock" }, { file: "main-22-theclimb.png", label: "The Climb" }, { file: "main-08-tunnelsafety.png", label: "Tunnel Safety" }, { file: "main-09-findfamily.png", label: "Find Family" }, { file: "main-28-assembly-qv-tally.png", label: "Assembly" }, { file: "main-30-fairdraw-reveal.png", label: "Fair Draw" }, { file: "main-33-sky-post.png", label: "Sky" }, ]; // --------------------------------------------------------------------- // Timeline builder. A single running cursor lays out ordered SEGMENTS with // a small crossfade overlap. Two layer classes: // - overlay segments (data open, chapter cards, wall): full-screen panels // that crossfade OVER the phone stage. // - stage segments (act footage, assembly): the phone/field beneath. // --------------------------------------------------------------------- const XF = 0.5; // crossfade overlap between consecutive segments const DATA_DUR = 7.0; const CH_DUR = 3.1; // chapter card window const WALL_DUR = 7.0; function clipDur(clips, name) { const v = clips.find((c) => c.name === name)?.durationS; if (!v) throw new Error(`clip ${name} missing/zero duration in manifest`); return v; } // --------------------------------------------------------------------- // Per-mini-app content (REDESIGN-5: large/short plain-language text, real // continuous footage, no ledger/terminal motif). // // SHIP-NOW FALLBACK: a from-scratch per-app recapture (dedicated 8-12s // clips) hit a real, now-fixed LP-solver bug (src/lib/farms.ts) plus an // intermittent Health Post hang mid-run; under a hard deadline this build // instead reuses the already-captured, already-verified act1/act2/act3 // footage (capture-manifest.json's real `beats`), playing each app's own // real sub-window of that shared clip CONTINUOUSLY (never a frozen still - // the one thing being fixed) via `mediaStart`/`dwell`. These are the same // real, frame-verified offsets the previous (frozen-snapshot) build used - // only the playback mechanism changed (continuous real video, not a single // extracted PNG) and the window no longer pads past that real dwell with a // hold. Per-app dwell is therefore shorter than the 8-12s target here // (disclosed risk - see DoneClaim); a true recapture with longer per-app // dwell is the follow-up, tracked separately. // `type` is the real signed event the app emits mid-clip (optional small // caption, shown as a plain tag - no hash, no JSON, no monospace). // --------------------------------------------------------------------- const APP_BLURBS = [ { id: "waterwatch", act: "act1", assetKey: "act1", mediaStart: 1.97, dwell: 5.63, label: "Water Watch", type: "waterwatch.reading.report", headline: "Catches bad water before anyone drinks it." }, { id: "fairshare", act: "act1", assetKey: "act1", mediaStart: 7.95, dwell: 0.85, label: "Fair Share", type: "fairshare.need", headline: "Splits power, water, and food fairly, automatically." }, { id: "tunnelsafety", act: "act1", assetKey: "act1", mediaStart: 9.25, dwell: 0.80, label: "Tunnel Safety", type: "tunnelsafety.hazard.report", headline: "Reports a blocked tunnel so everyone reroutes instantly." }, { id: "findfamily", act: "act1", assetKey: "act1", mediaStart: 10.4, dwell: 1.40, label: "Find Family", type: null, headline: "Finds missing family, privately. No one else sees your search." }, { id: "farms", act: "act2", assetKey: "act2", mediaStart: 2.4, dwell: 0.9, label: "Farms", type: "fairshare.contribution", headline: "Plans crops from real weather and power data." }, { id: "housing", act: "act2", assetKey: "act2", mediaStart: 4.8, dwell: 3.7, label: "Housing", type: "housing.space.report", headline: "Assigns rooms fairly \u2014 and remembers who got shorted." }, { id: "mentor", act: "act2", assetKey: "act2", mediaStart: 9.4, dwell: 1.4, label: "Mentor", type: "mentor.match", headline: "Matches you with a mentor before a skill is lost." }, { id: "healthpost", act: "act2", assetKey: "act2", mediaStart: 11.2, dwell: 3.1, label: "Health Post", type: "healthpost.referral", headline: "Triages symptoms, then signs a referral to a clinician." }, { id: "lightclock", act: "act2", assetKey: "act2", mediaStart: 14.8, dwell: 0.8, label: "Light Clock", type: null, headline: "Tracks your sleep rhythm without sunlight \u2014 no sensor required." }, { id: "theclimb", act: "act2", assetKey: "act2", mediaStart: 16.8, dwell: 3.5, label: "The Climb", type: "theclimb.plan.propose", headline: "Schedules the climb to the surface so no crowd crush happens." }, { id: "qvballot", act: "act3", assetKey: "act3", mediaStart: 0.5, dwell: 7.8, label: "Assembly", type: "governance.qvBallot", headline: "Keeps votes and lotteries running \u2014 network or not." }, { id: "fairdraw", act: "act3", assetKey: "act3", mediaStart: 8.9, dwell: 2.5, label: "Fair Draw", type: "fairdraw.commit", headline: "Runs a lottery no one can rig." }, { id: "sky", act: "act3", assetKey: "act3", mediaStart: 13.2, dwell: 5.6, label: "Sky", type: "sky.morale.pulse", headline: "A shared mood board for the whole shelter." }, ]; // Lay out one act's apps back-to-back (hard cuts between apps). Each app's // window is its own real, already-verified dwell within the shared act clip // (see APP_BLURBS header note) - played CONTINUOUSLY from `mediaStart` for // `dwell` seconds, never a frozen still. Returns the stage's total duration, // the per-app text entries (synced 1:1 to each clip's start), and the //