--- name: code-rendered-motion-graphics description: Use when coding promo motion graphics videos. version: 1.0.0 author: HamaratLabs license: MIT metadata: hermes: tags: - video - canvas - ffmpeg - motion-graphics - rendering related_skills: - p5js - manim-video - ascii-video --- # Code-rendered motion graphics ## When to Use Use when a promo, explainer or brand video must be produced from code rather than filmed or AI-generated footage; when a brief names an external video generator that is not connected and the scenes must be drawn instead; or when an approved cut needs a new variant (different character, palette, language) without disturbing the shipped film. For promo, explainer and brand videos drawn entirely in code — no stock footage, no talking head, no third-party music. Pipeline shape that works on this machine: a drawing module + `studio.html` + a `render.mjs` that serves locally, drives headless Chrome over CDP, dumps PNG frames and muxes with FFmpeg. ## 1. Inventory before proposing anything - Find the existing video project and `ffprobe` its shipped output for real duration, size, fps and streams. Status docs and `SONUC.md`-style notes go stale; the MP4 and the code are the truth. - Confirm the renderer still runs by rendering 2-3 stills from the **existing** project before promising a new one. A pipeline that worked months ago may need no change, but say so only after it actually rendered. - Check which named assets the brief assumes (narration WAV, transcript, external video MCP). If one is absent, say so plainly and offer the code-rendered substitute instead of stalling. ## 2. Never edit the approved cut in place - Each new look, character or language is a NEW directory `variants/-v1/` with its own copy of art/motion/render/studio/tests. The previously approved sources and final MP4 must stay byte-identical. - Hash the protected sources before and after rendering and fail the render if they changed — a renderer that writes into shared `out/` will silently overwrite the shipped film. - When cloning a variant, rename the output file AND the assertion in the delivery test in the same edit. A renamed MP4 with an un-renamed assertion keeps passing against the previous variant's file and hides that nothing new was encoded. ## 3. Gate the render Order: storyboard → contact sheet → short preview (about 6 s) → **user approval** → full render. Do not spend a full-length encode before the look is approved; say explicitly in the report that the full render has not been produced yet. - The contact sheet must sample scene centres **and** every transition midpoint. Transition defects exist only at the boundaries and are invisible in centre-only sheets. - Keep animation a pure function of time with a seeded hash; no `Math.random()`. Determinism is what lets a later frame-exact rerun and the delivery test mean anything. ## 4. Look at the frames with your own vision Rendered stills must be inspected visually before reporting, every time. Code that reads as "apple body with stem and leaf" renders as a pear with a flagpole; only the image shows it. Check in this order: silhouette reads as the intended object, limbs attach to the body, character sits on the furniture rather than floating, headline and label text fully inside the safe area, Turkish diacritics intact. Silhouette construction rules, the deadpan-face recipe and the full per-still checklist: `references/character-and-layout-review.md`. ## 5. Transitions over text Cross-fading two text-heavy scenes double-exposes the headlines and both become unreadable mid-transition. Use a travelling clip-rect wipe (optionally with a thin accent edge at the wipe line) so type is always fully inked. ## 6. Sound - Synthesize original SFX (damped oscillators + seeded low-passed noise). No narration unless a real recording exists, no third-party music. - Parameterize the SFX generator by duration (e.g. a `--full` flag selecting the event list, output name and report name) and extend the event list onto every transition beat of the longer cut. FFmpeg will mux a short bed under a long video without erroring, leaving most of the film silent; length parity is never checked for you. - Report measured peak/RMS dBFS and state that the mix was verified by measurement, not by ear. - Without a narration recording, never present scene timings as beat-synced. Label them as a draft timing derived from the existing cut. ## 7. Acceptance evidence Re-run these yourself even when a subagent reports success — a child's summary is a self-report: ```sh node --check art.mjs render.mjs TMPDIR="$BH_SCRATCH" node render.mjs --sheet TMPDIR="$BH_SCRATCH" node render.mjs --preview node --test test-motion.mjs test-delivery.mjs ffprobe -v error -show_streams -show_format -of json out/.mp4 ``` Point `TMPDIR` at the Hermes scratch directory so headless Chrome writes its profile there. The delivery test should assert codec, resolution, fps, frame count, duration **and** a distinct-frame count, so a frozen render cannot pass. After approval, the full render is the same renderer with a `--full` flag that walks every frame of `DURATION * FPS`. Start it as a tracked background process with notification and poll it — a full-length encode runs for minutes, and a foreground timeout above the cap is promoted to background anyway, so requesting a huge foreground timeout only costs you the result handle. Verify the finished full render yourself with an independent distinct-frame probe, not only the delivery test: decode with `-vf fps=1`, hash each sampled frame, and assert the sampled count equals the unique count. Write that probe to a scratch `.py` file and run it; the same code inlined via `python3 -c` inside a shell pipeline silently yields zero samples, because commas in an FFmpeg filter string need escaping that differs between the shell and the filter parser. ## 8. Reporting to this user Turkish, short, structured. Separate what was actually rendered and verified from what was not ("21 saniyelik tam render alınmadı"). Attach the contact sheet and the preview MP4. Put questions at the very end under their own bold **Sorular** heading, never mid-prose. Before relaying a delegated child's work, confirm its named artifact exists on disk. A child that ends without writing the file it was asked for has produced nothing to report; state the gap and offer to re-dispatch rather than summarizing findings you cannot point at.