scenario-kinetic-music-video
Use when turning a song into a kinetic-typography or motion-design music video, lyric video, visualizer or K-pop style MV with Scenario, landscape or vertical 9:16 for TikTok, Reels and Shorts: a generated subject sheet, style frames and footage, plus a deterministic JavaScript/t
Install
npx skills add https://github.com/scenario-labs/skills/tree/main/skills/scenario-kinetic-music-video
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install scenario-labs-skills@llmmart
git clone https://github.com/scenario-labs/skills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole scenario-labs/skills collection as a plugin from our marketplace. Git is the plain clone.
README
scenario-kinetic-music-video (maintainer notes, not packaged)
Origin
Sara Nemati own kinetic-music-video skill, built from the production of the Every Scenario music
video (and the kinetic music video it grew out of) and rewritten to be generic: any subject or none,
any looks, no project examples. Brought into this repository from the ZIP she exported on
2026-10-02.
Edits for this repository
- Frontmatter reduced to
name,description("Use when", under 500 characters) andlicense; the name carries thescenario-prefix. - Generative model names and ids removed (availability differs per team): lanes are named by
capability and found with
recommend. Parameter names are the ones that held at authoring time, with the schema as the authority. - Credit amounts stated as relative costs, with
dry_runbefore paid steps. - En and em dashes replaced, scripts print usage when called without arguments, and the
output-writing scripts refuse to replace an existing file without
--force. - Sibling references and the install invitation added; connection setup points to
scenario.
Portrait canvas
Added after import so the skill can serve vertical feeds. One canvas per project (CANVAS in the
timeline), with --canvas for a second ratio. assets/engine/canvas.js holds the presets, the 9:16
safe band (derived from the band scenario-formats and scenario-video-ads compose to, reading
their 6 to 13% per side as 6% left and 13% right, where the action rail sits), the per-canvas
timeline filter and plateFit. The HUD, the house subtitle and the scene template lay out inside
E.SAFE; every portrait-only behavior is gated off landscape.
Verified headless (Playwright's Chromium, software WebGL) with synthetic audio, lyrics and a
synthetic footage clip (frames, matte, tracking): landscape stills of both template branches
(footage and 3D) and the HUD, including a 150-character lyric line, are pixel-identical to the
pre-change engine at scales 1 and 0.5. Portrait and square stills were checked by eye with the safe
band outlined, and the error paths (bad canvas, bad timeline tag, an --only with nothing to
render) fail fast. canvas.js has a unit suite. Two plan-only application tests (portrait only;
both ratios) passed with notes.
A live application test then produced a full 1080p60 portrait video end to end (a 2:14 song, 24
style frames, 27 clips, 9 section agents, about 15k CU) and passed with notes. It found the portrait
subtitle running into the HUD counters, a crop that stretched plates, a --chant window with no
end, transcription passes overwriting each other, still.mjs keeping a stale sheet, and the doc
gaps behind a mic-covered lip-sync retake, the 720p-only cost anchors and a rejected reference crop.
All are fixed; motion_library.md §10 notes one production behind its portrait rules.
Dynamism gate
Added so a render is held to numbers per section, not to an eye that adapts after a few watches.
scripts/dynamism_check.py gates a render and measures references; scripts/rectify_screen.py
flattens a phone-filmed screen first, since a reference often arrives as a phone filming a TV or a
laptop, and motion read off that raw video measures the hand.
How the measurement was chosen, all on synthetic clips encoded with libx264:
- A 60 fps clock and distinct frames. Each picture of 24 fps footage repeats 2 or 3 times in a 60 fps render, so frame-to-frame differences read a live clip as mostly still. A first design compared frames 0.1 s apart. It fixed the repeats, but its flow saturated near 12 px per frame and then fell as speed rose: pans at 18 to 96 px per frame all read 4 to 6. A 1-frame toggle or a 3-frame shake also compared identical phases and read fully still. The script now runs optical flow between consecutive distinct frames, skips repeats, and averages 0.5 s windows (whole 24, 25 and 30 fps cycles).
- Flow range. OpenCV's dense flow pyramid stops at 32 rows, which capped it near 16 px at the 320 px analysis size. A 1/8-size pass seeds it, and a whole-frame shift catches whip pans beyond that. Constant pans from 3 to 192 px per frame read strictly increasing, within 7% of true at native 60 fps and within 8% as 24 fps footage.
- Still runs at frame resolution. Fixed 0.1 s steps read a 0.60 s hold as 0.5 s, which passed the high limit. Runs now end on the frame, and a 0.60 s hold reads 0.60 s. The still test uses a gray difference of 12, not 24: at 24, a 6 px per frame pan of 24 fps footage over soft texture read 44% still.
- Slow moves add up. A still run first ended only on per-pair flow of 1 px or a pixel change.
Sub-pixel drifts at the calm (0.5) and mid (1.0) motion floors then split into short runs that all
read 100% still, and a 10% push-in over 2 s read 97% still. A run now also ends once the flow from
its first frame reaches 0.25 px at 320.
- The limit was 0.4 first. 24 or 25 fps footage shows only 2 new pictures in a 0.1 s run, about 0.4 px at the calm floor, so a calm drift and a 10% push-in read 12 to 93% still there.
- At 0.25, both read 0% still at 15, 23.976, 24, 25, 29.97, 30 and 60 fps drawn at twice the analysis size, and at 24, 25 and 60 fps rendered at 1920 x 1080. Drawn at 320 itself, a drift still read up to 23% still at 24 and 25 fps (53% at 15): libx264 holds some of its sub-pixel steps.
- Gaussian grain of sigma 1 to 3 gray levels on a hold measured 0.01 to 0.17 px from the run's first frame and reads 100% still. CRF 23 smooths grain past the pixel test: there, sigma 3.4 to 4 read 70 to 100% still at 0.25, and sigma 3.4 only 70 to 83% at 0.2, so the limit stops at 0.25. At CRF 12, the pixel test breaks a hold from sigma 3.8, as before.
- That flow call runs only once the per-pair steps since the run began sum to half the limit, so a clean hold or a fast move never pays for it.
- Decoded size. ffprobe reports a phone clip's coded size, before its rotation tag. A portrait
clip stored landscape read as a landscape canvas, with 45% less motion. The size now comes from a
decoded frame, as in
rectify_screen.py. - A flash is one cut. Cut frames within 3 frames of each other merged, so a white flash of 4 or more frames (2 in a 30 fps preview) read as two cuts. A cut back to the previous shot within 0.15 s now ends the same cut; a strobe counts one cut per flash.
- Flashes follow WCAG 2.x general flashes: a pair of opposing changes of 10% relative luminance, the darker state under 0.80, on the frame mean, at most 3 per second everywhere. Counting each change as a flip would have failed a white flash on every beat at 120 BPM; the pair reading allows it and still fails full-frame 8ths.
- Speed. Flow runs on every distinct pair, in 4 threads. A 10 s 1080p60 test pattern measured in about 1 s (3 s on one thread) on an M-series Mac at authoring time.
Default targets are uncalibrated: they were checked on synthetic fixtures only, never on a real
render. Calm allows a 1.0 s hold, not more, because the quality bar says no static frames.
Calibration is pre-registered for the next live /skills:validate run, which gates every section of
its render:
- An approved section that fails: loosen that energy's default to its measured value with the
--write-targetsmargins (still + 0.10, hold × 1.25, motion × 0.7). - A section the grader calls static that passes: tighten that energy's default to its measured value.
- Approved sections pass and static ones fail: keep the defaults, and drop the "uncalibrated" hedge once a second production agrees.
- A flash failure is never loosened: the limit is a safety rule, not taste.
rectify_screen.py on a synthetic handheld clip (zoom 3%, drift 14 x 9 px, a caption band):
- manual corners: mean error 1.3 of 255 against the true screen content;
- auto detection: corners within 5 px, error 2.8 of 255, 100% of frames tracked;
- median motion: 4.7 on the true content, 6.5 off the flattened screen, 1.4 off the raw phone clip.
Known limits:
- The numbers are frame-wide. Frozen footage under moving type passes, and a lip-sync close-up where
only the mouth moves reads still;
freezedetect, the contact sheets and dynamism.md §7 cover them. - Flashes on part of the frame are not measured.
- Auto screen detection needs a screen brighter than the room. A live
/skills:validaterun filmed black bars around a vertical video: the room outscored the screen, and its outline filled the frame. Such an outline now exits "no screen found", after writing the--checkframe. Quadding the video itself tracked 100% of frames. - The same clip inside black bars (a landscape recording posted as a vertical video) outlined the
whole recording and failed on texture, with no
--quadhint. Detection now crops the bars first, and the clip exits "no screen found" as it does without them. --write-targetstakes span energies as given. Labeling spans by how busy they look once held a calm section to more motion than a mid one, someasurewarns when targets run out of order. It checks the targets the gate will use: a calm-and-high file still meets the default mid.- Sections come from
nodeevaluatingengine/timeline.jsas adata:URL module. A timeline with relative imports falls back to a file URL, which needs a Node that detects ES modules in the project's typelesspackage.json(20.19+ or 22.7+). scaffold.shcopies the scripts intotools/on every run, but itscp -nkeeps an existing project'sENGINE_API.mdandAGENTS_BRIEF.md, and rerunning it reinstalls the environment. So SKILL.md step 6 tells a revision of an older project what to copy by hand: the brief is filled in per project, so only its dynamism check is added.
4K master
--scale 2 reuses the canvas: layouts already scale with E.SCALE. Three things did not, and each
fix applies above scale 1 only, so the shader text and the encoder arguments at scale 1 or below are
unchanged.
- Bloom: UnrealBloomPass blurs in texels of its own targets, so at 4K the glow reached half as
far. It now runs at the scale-1 size. Its bright pass then read only the middle of each 4×4 block,
so it averages the block with four bilinear taps instead: without them, thin lines pulse as they
move.
- The engine supplies that bright pass whole instead of patching three's shader text, which a
reformatting release would break with no CI test to notice (the repository installs no three).
It relies only on the uniforms UnrealBloomPass feeds, and boot refuses
--scaleabove 1 if one goes missing. Seven 4K stills match the text-patched version byte for byte.
- The engine supplies that bright pass whole instead of patching three's shader text, which a
reformatting release would break with no CI test to notice (the repository installs no three).
It relies only on the uniforms UnrealBloomPass feeds, and boot refuses
- Grain and scanlines keep 1080p cells (string substitution in the final shader).
- Encoder: above 1080p,
-levelfrom H.264 Table A-1, a VBV cap from that level, and-threads 4;render.mjscaps the workers to memory and refuses a 4K master past Level 5.2.- CRF alone has no ceiling. On a real project with grain 0.06 over footage, 3 s of 4K60 at CRF 17 peaked at 296.6 Mb/s in its busiest second, against the 300 Mb/s Level 5.2 High allows.
- The cap is the level's Main MaxBR (80% of the High limit) with a buffer of a quarter of it, so no second inside a chunk passes the High limit. The same 3 s then peaked at 262.2 Mb/s (252.7 average), at 41.5 dB against the uncapped file.
Evidence (an M-series Mac, ANGLE Metal, three 0.186.1, ffmpeg 7.1.1, a synthetic project with a footage plate, matte and tracking, 2D and 3D type, grain, scanlines and the HUD):
- Unchanged at scale 1 or below: stills of every frame at scales 0.5 and 1, plus square and
portrait, are pixel-identical to the previous engine. Four
render.mjsfiles (960×540 at 30 fps on 2 workers, 1920×1080 at 60, 540×540 at 30, 1080×1920 at 60) are byte-identical.- Chrome's GPU canvas rasterizes large or scaled glyph edges with ±1 differences from run to run,
in the old engine as in the new. The comparison runs with
--disable-accelerated-2d-canvas(3 of 3 repeat runs identical), so a difference can only come from the engine.
- Chrome's GPU canvas rasterizes large or scaled glyph edges with ±1 differences from run to run,
in the old engine as in the new. The comparison runs with
- Moving thin lines (0.5 to 1.5 px wide, half a 1080p pixel per frame), per-frame halo energy against 1080p: within 0.6% with the fix, up to 148% off with the bloom resized alone, 129% off with no fix. Area-downscaled PSNR against 1080p: 39.3, 27.9 and 24.2 dB.
- Grain: 4K grain is constant over 2×2 cells and correlates 0.79 with the 1080p pattern (−0.04 before), the rest being 8-bit rounding near black.
- Levels:
h264Levelmatched x264 medium's own pick in 30 cases from 176×144 to 5120×2880, so the pin changes no bytes at 4K60; a vitest case reruns that on CI's ffmpeg. With-preset slow, x264 signals 5.0 at 1080p60 on its own;-level 4.2makes it drop to 4 reference frames. - Cost: a 4K frame took 3.3 times as long. Peak footprint per worker (Chrome, its GPU process
and x264) was 2.5 GB at 1080p and 5.3 GB at 4K;
workerGBadds about a gigabyte for real footage caches. - three 0.187.0, which main moved to while this work was open, on 2026-11-07: the bloom, composer and shader addons are byte-identical to 0.186.1. On a real project with footage, mattes, 3D type, bloom, grain and scanlines, 9 stills at scales 1 and 2, and 3 with blur, are byte-identical on both versions; at 0.5, one pixel of one still differs by one level. Repeat runs were identical on each version.
- Older project: on a project made before the portrait canvas, the
pipeline.md§7 copy withoutcanvas.jscrashed the page, sincemain.jsimports it. With it, a landscape still matched the old engine at 48 dB. The same project's 4K stills showed the per-section check working: itsTHREE.LineSegmentsedges stay one device pixel wide, so they glowed less than at 1080p.
Motion blur
In-engine GPU accumulation, opt-in per project (BLUR in timeline.js).
- Design:
renderTimekeeps the frame pass as it was. Whenblur.jsplans sample times, the blurred layers render again at each, every composite is added into a float32 target, and the sum divided by n replaces the frame's composite before bloom and the final shader, which run once.render.mjsstill grabs one JPEG per frame.- Exact for static content: each composite is half-float, a sum of up to 24 equal half values is exact in float32, and dividing by n restores the value.
- Sharp layers (
blur: false, the HUD) keep the frame pass's render target in every sample. Every blend mode is linear in the layer below, so this is exact too. - The shutter opens at the frame time, so nothing shows before its onset. A cut inside it slides it back, never before the previous cut.
- Cuts: entry bounds,
E.cut, and word switches (w.s - LEAD). Without them, a hero word swapped on its onset showed both words in one frame of the fixture. Beats are opt-in: a cut per beat shifts the streak on about one frame per beat. trackAtreplays the frame pass by call order, per layer. Recomputing from the sample time crosses clip frames; matching by clip time first picked the wrong call when a clamped label's time coincided with a slow-motion one (ablur.test.tscase pins it). One order across layers let a sharp layer's calls, orprepare()'s, shift a blurred layer onto another call's landmark (core.test.tscases pin both).- A sample drawing a clip that
prepare()did not advance (an undeclared switch inside a scene) makes the frame fall back to its frame pass, copied aside before the samples. - Without
EXT_float_blendthe sum ping-pongs between two float targets, bit-identical to blending. - Off by default: existing projects render unchanged, 8 samples cost about 2.2 to 2.5 times the render time, and the director approves the look on sharp previews.
- Default samples, 4 against 8: type moving 2400 px/s and a box spinning 9 rad/s, 180° at 60
fps, against 64 samples on the moving band. 4 samples: 34.9 dB mean, 31.0 worst, with visible
copies on the type. 8: 41.5 and 37.7. 12: 45.6 and 41.9. No blur: 21.0. Frame time with the PNG
grab: 79 ms without blur, 122 at 4, 195 at 8, 265 at 12. Hence 8, with
E.fastfor slams. - Byte-identity protocol (headless Chrome, ANGLE Metal,
--disable-accelerated-2d-canvas, the synthetic project of the 4K evidence above):- Blur off: every frame of the 6 s project at scales 0.5 and 1, square and portrait, matches the
previous engine, and the four
render.mjsfiles are byte-identical. - Static content with blur on: 90 of 90 frames identical to blur off at 1080p and 5 of 5 at 4K, with float blending and with the ping-pong path; SwiftShader the same on 3 frames.
- Labels tracked at clip time t, t/2 and a clamp: 180 of 180 frames identical with 8 samples; 32 differ without the replay.
- An undeclared clip switch: that frame comes out identical to blur off and
render.mjslists it; withE.cut, it blurs and its plate matches blur off. - A scene throwing inside a sample: the frame state comes back, and the next frame matches a clean run.
- To rerun it, render frames through
window.renderFramewith the old and the new engine and compare hashes; the vitest suites cover the planning, not the pixels.
- Blur off: every frame of the 6 s project at scales 0.5 and 1, square and portrait, matches the
previous engine, and the four
- Not covered: camera moves made with
E.post(punch, shake, rot) stay sharp, and roto materials or custom textures are not checked for stale clips.
What the record does not cover
- The skill is the creator's own document, not distilled here, so it does not follow the house
layout for recipe skills: its
references/lessons.mdplays the Common mistakes role. - Costs are the production's observed relative prices, not live quotes.
- The engine and scripts need Node with Playwright, ffmpeg and a Python environment
(
scripts/scaffold.shbuilds it); the matte tool needs macOS (Apple Vision). - Tests cover the dependency-light scripts, the dynamism and rectify scripts on synthetic clips,
canvas.js,blur.js, the clip and tracking logic incore.js,render_lib.mjsanddelivery_check.py; the rest need the full environment and generated footage. - The 4K path and motion blur were checked on synthetic projects only, not yet in a live application test.
Supply chain
What the setup and analysis scripts fetch, and how each source is pinned:
- npm: exact direct versions and a v3 lock with integrity hashes, installed with
npm ci --ignore-scripts. - Python:
assets/python/<platform>.txtpins every package, transitives included, by version and SHA-256, wheels only. Installing builds nothing, so no build backend or compiler toolchain is fetched. Each run rebuilds.venvfrom the lock alone, with noensurepip, so no unlocked pip. Only macOS arm64 and Linux x86_64 (manylinux 2.28, so glibc 2.28+) have locks: on Linux aarch64,demucsneedssphn, which has no wheel there, and its source build fetched a Rust toolchain and failed. - beat-this: PyPI 1.1.0. Its provenance attestation names CPJKU/beat_this commit
ad7974846029835307ba19a3d5cefbf40b243041(tag v1.1.0), and the wheel's package files are identical to that commit. uv refuses a Git requirement in hash-checking mode, so the attested wheel is how the commit is pinned. - Fonts: google/fonts at one commit. Each file the scaffold downloads, and its family's
OFL.txt, is checked against SHA-256. A mismatch removes the download and stops the scaffold. Files already inassets/fonts/are kept as they are, unchecked. - beat_this checkpoint:
audio_analysis.pydownloadsfinal0once intomodels/, checks its SHA-256 on every run, and passes the local path, which beat_this loads withweights_only. Given only the name, beat_this would fetch it unverified and unpickle it. - Whisper:
lyrics_align.pyloadsSystran/faster-whisper-large-v3at a fixed Hugging Face commit.
Regenerate the locks after any change to requirements.in, with uv 0.13.0: run the command in each
lock's header, moving --exclude-newer to the date you resolve on. The offline checks in
tests/scenario-kinetic-music-video/test_python_lock.py run in pnpm test.
.github/workflows/kinetic-locks.yml re-resolves both Python locks to prove they reproduce, then
installs each on its platform and imports the tools' modules. It also installs the npm lock with
npm ci --ignore-scripts and imports its three packages.
Verified on 2026-10-29, with no Scenario calls:
- The real scaffold ran in a
node:22-bookwormcontainer (linux/amd64, uv 0.13.0) and natively on macOS arm64: fonts, licenses,npm ci, the hashed Python install, every import, andaudio_analysis.pyon a synthetic 120 BPM click track (read back as 120 BPM). - A tampered checkpoint was rejected and removed. The test suites cover a tampered font.
- The scaffold's test suite checks the platform choice, the hashed wheels-only install, and that a font mismatch installs nothing.
Remaining gaps:
uv venv --python 3.11downloads a managed CPython when none is installed. uv verifies it against checksums built into uv, but uv itself, Node, npm, ffmpeg, Chrome, and swiftc are the user's.- Demucs downloads
htdemucsweights fromdl.fbaipublicfiles.com, checked only against the short hash prefix in the file name, then unpickles them. - The Whisper commit pins which files are fetched; whether huggingface_hub verifies their content was not checked.
- MediaPipe's legacy solutions ship their models inside the hashed wheel; nothing else downloads at run time as far as the scripts show.
Skill manifest
Kinetic Music Video
A song goes in. A 1080p60 music video comes out, landscape for YouTube and X or vertical for TikTok, Reels and Shorts: a motion designer's showreel cut to the track. Kinetic type, 2D and 3D graphics and transitions land on the beats and sung syllables. Generated footage of the subject is woven through it where the concept wants a performer. The approved master is the only soundtrack. Preserve the original; an authorized audio edit produces a new, versioned master.
The work splits by what each tool does best:
- Scenario supplies what code can't: a consistent subject with real physics, choreography, hair and lip-sync, in whatever art style each section needs.
- The JS engine supplies what video models can't: exact typography, frame-exact timing to onsets and beats, infographics, compositing around the subject, and endless re-renders at zero generation cost.
- Sub-agents give each section a dedicated designer. A shared style bible and a verification loop keep them coherent.
Connection and the core generation loop: see the scenario skill in this repo. For a song-to-video
cut without the engine, see scenario-seedance-music-video. If a sibling skill named here is
missing from your available skills, load it with skill_get (Scenario MCP) or ask the user to
install it (https://github.com/scenario-labs/skills#install); unattended, proceed from tool schemas
and flag the gap.
Read references/lessons.md before starting. Every item in it cost real time or money once.
references/motion_library.md is the design menu.
Before you start (ask once, then run)
- Workspace: the Scenario team and project (
teams_list; ask if there is more than one). - Subject:
- Who or what performs: a character from reference images, a mascot, a product, the artist's own likeness (their own photos and consent only), or nobody (a pure motion-graphics or lyric video).
- Footage share: performer-led, a mix (often about 60/40), or graphics only.
- Look:
- Ask for references: images, videos or links for the mood, the motion and the color. Vague color asks without references drift to safe palettes.
- Decide the 2-4 looks and which sections own which.
- Ask what must never appear.
- Defaults: generated footage shown clean (no filters on it), graphics layered on and around it, a fast and upbeat showreel energy.
- Brand: any logo, wordmark or credit. Use official files in their official colors, only where the director wants them.
- Budget: lean (6-10 video generations), moderate (12-20) or big. Price each paid step with
dry_run(one run per distinct payload, then total) before spending. Relative anchors at 720p: a 6 s clip costs about twenty style frames, a 10 s clip about thirty-five, and a full mixed video about five hundred. A 1080p clip measured about 2.5 times its 720p price, so settle the footage resolution before quoting. - Format: one canvas per project, asked once: portrait 9:16 for TikTok, Reels or Shorts,
landscape 16:9 for YouTube or X (unattended with no destination: landscape). It is
CANVASinengine/timeline.js, and style frames and footage are generated at that ratio, never cropped from the other. On portrait, check the destination's current length cap and plan the teaser as the platform cut when the song runs longer, or when you cannot check. Both ratios only on request: the code re-renders free with--canvasand most shots are windowed, but each shot that must fill the second frame (hook, lip-sync close-ups, finale) is paid again (references/pipeline.md§9). X caps standard accounts at 2:20, so plan a teaser. - Lyrics: use them if supplied (they beat any transcript). Otherwise transcribe and flag the uncertain words at the end.
With no one around to answer, choose sensible defaults for the creative choices and write them into TREATMENT.md. Do not default the money: with no stated budget or no explicit team and project, stop before the first paid step and say what is missing.
Workflow
1. Scaffold and analyze the song
Run bash <skill>/scripts/scaffold.sh <song> inside a new project folder (macOS on Apple Silicon or
Linux x86_64 with glibc 2.28+: the Python lock covers those two), then follow
references/pipeline.md §2:
audio_analysis.pywrites stems andengine/data/audio.json: beats, downbeats, kick/snare/vocal onsets, and 60 fps envelopes. Measure the tempo; labels lie (a "130 BPM" song was 98 with double-time drums).lyrics_align.py transcribe, then hand-correctanalysis/lyrics.txt, thenlyrics_align.py alignwritesengine/data/lyrics.jsonwith word onsets.- Check timing by eye with
plot_lyrics.py. Audition when playback is available; a spectrogram locates onsets but cannot prove pronunciation or musical continuity.
1a. Edit the soundtrack when requested
For pronunciation repairs, lyric changes, section replacements or structural cuts, read
references/audio_editing.md. Use scenario-ace-step for its
Cover/Repaint contracts. Keep the current cut and master until a candidate is selected; preserve
audio outside the agreed window and rebuild affected timing data after applying it. A picture-only
revision reuses the approved soundtrack.
2. Research (parallel, background)
Launch two sub-agents with web access while you work on other things:
- Culture: for the song's subject, find recognizable events, memes and visual tropes, each with a verified fact, its iconic visual form, an insert idea and a short on-screen string.
- Craft: study the user's motion references (download them, contact-sheet them, read the
frames), plus genre direction techniques. Extract timing numbers, color hex values and
implementable JS moves. Measure each reference per section into
analysis/targets.json(references/dynamism.md §5).
Save the condensed results as analysis/research_*.md. Scene agents read them alongside
references/motion_library.md.
3. Concept, style bible and treatment
- Give the video a spine. The strongest concepts make the edit itself carry the song's meaning: a device that progresses through the whole video, for example a counter, clock or countdown that moves with the song while the cut rate or the looks escalate with it. The spine usually lives in the HUD counters.
- STYLE.md (the law):
- a one-line concept and the spine
- the footage rules (clean plate and the back/mid/front layers, or another policy)
- the looks, each with ground, ink, accent, rendering rule and matching footage style
- the palette with roles
- 4-5 type roles with named fonts
- lyric display rules
- a motion grammar mapping beats to effects, with the cut density per section
- the subject (identity, design details usable as graphic motifs)
- brand rules, references and bans
- TREATMENT.md:
- song facts and the energy map
- the arc
- the hook for the first 3 seconds (the strongest idea in the video, and it must work as a muted autoplay)
- one row per section: time range on downbeats, lyrics, look, must-have ideas
- a footage map (filled in as clips land)
- PLAN.md: a one-page version for the director to approve before you spend on footage (unattended, this is the stop point if the budget is unstated).
4. Subject, style frames and footage on Scenario
Skip this for a graphics-only video, apart from any stills or 3D props. Otherwise follow
references/pipeline.md §3-5:
- Subject sheet: a turnaround, expressions and callouts from the user's references. Look at it, then crop identity references from it.
- Style frames: one still per shot at the canvas ratio (an image model that takes reference images), in its section's look. Compose with negative space for type (on portrait, the face and the type space inside the safe band), on a set that composites (black void with rim light, flat color cyc, or white high-key). No text. In a lip-sync frame nothing covers the mouth (no mic, hand or prop): a covered mouth fails the sync check and is paid again. Contact-sheet them and get the look approved cheaply (unattended: proceed only inside a stated budget).
- Footage routes:
- Image-to-video from the frame for actions.
- A video model with reference images and reference audio, given a synthesized beat track for dances that lock to the song, then beat-warp.
- Audio-to-video from a frame plus a vocal-stem slice for lip-sync. The alternative is reference-audio video plus a lip-sync correction model.
- Code instead of generation for networks, charts, UI and particles.
- Never send the song to a video model. Turn the model's native audio off when its schema offers it
(the render takes sound only from the master either way), and launch in waves within the team's
concurrency ceiling (
jobs_waitre-called withpending_job_ids, neverjob_get). Relaunch only a launch refused with 429parallel-custom-jobs: it created no job, and dropping it leaves a hole in the cut. - Prep every clip with
tools/prep_clip.sh: frames, a subject matte (Apple Vision, with Scenario background removal as the fallback; seereferences/pipeline.md§5) and tracking (MediaPipe pose plus the matte bbox). Inspect the mattes. Write each clip's content, key moments, slot and matte quality into the footage map.
5. Engine and scene agents
- Smoke-test first:
- Set
PALincore.js, and inengine/timeline.jssetCANVAS, the sections on downbeats with theirenergy,HUD(title, mark, section codes, spine counters) andPOST(neutral by default). - Write a tiny
_smoke.js: plate → type behind the subject → matte → tracked label. - Render one still and a 5 s clip, then confirm audio and flashes line up with
av_sync_check.py.
- Set
- Brief the agents. Fill in
AGENTS_BRIEF.mdfrom the template, then launch one background agent per section in a single message. Each gets its file, time range, lyrics, must-have ideas and clips, and reads AGENTS_BRIEF, STYLE, TREATMENT, ENGINE_API and the research first. Log the agent ids. For a teaser or anything under about 30 s, the lead may write the scenes itself and skip the research agents, PLAN.md and the per-section agents; keep the smoke test. - Deliver clips as they land. Message the agent that needs each one ("clip ready: content, key moments, slot").
- Review every report. Contact-sheet the best stills and Read them. Fix engine-level problems yourself (they affect everyone) and tell the agents what changed.
6. Assemble, watch, iterate
- Render the full cut (3 workers, about 5 min for 2:00 on an M-series Mac, 2.5 times that with
motion blur). Wait for it in the foreground (or poll until it prints
wrote), then verify and deliver: never end the run mid-render or mid-encode, since a headless session that stops kills it. - Verify:
av_sync_check.py: expect 0.0 ms audio and 0 to +1 frame visual. Below a correlation of about 0.15 the visual lag means nothing (type leading byE.LEADreads as up to -3 frames): check onset stills instead.dynamism_check.py gateon each delivered render: exit 0. On exit 1, fix and re-gate (--forcereplaces its JSON); unattended, after 3 rounds on a section or at the budget, deliver and report the failing sections.freezedetect: no frozen footage.- Contact sheets at 0.5 s steps, 20 s per sheet.
- Every section boundary, frame by frame.
- On portrait,
still.mjs --safesheets, 20 s each: no word, logo or face outside the outlined band.
- Global look pass: a still sheet across all sections, then tune
POST, the palette and the HUD theme. Decide motion blur from an A/B of the fastest 5 s (--blur,references/pipeline.md§7; unattended: off unless the user asked for it, then judge the pair yourself). - Revisions: map each director note (they arrive as timestamps) to its section and send it back
to the owning agent via SendMessage. Resuming keeps its context. Fix a weak shot by replacing it
with a new generation in a different look, or with code, never by adding effects. Offer
alternatives as timeline
variants (render with--variant b) instead of guessing. - Older projects: without
tools/dynamism_check.py, copy it andrectify_screen.pyfrom<skill>/scripts/intotools/, and add the template's dynamism check toAGENTS_BRIEF.md. ReplaceENGINE_API.mdwithreferences/engine_api.mdonly whenengine/canvas.jsexists; otherwise add itsenergyline. Then tag eachTIMELINEentry'senergyfrom TREATMENT.md (references/dynamism.md§2).
7. Deliver
- 4K master: only on request (
--scale 2,references/pipeline.md§8), rendered first: every other file is made from it. - Videos: a master, an upload file (landscape: the master for YouTube, an X-ready file under 512
MB; portrait: the vertical upload in
references/pipeline.md§8), a teaser (verse plus first chorus), plus one file per variant. With both canvases asked for, one set per canvas, suffixed_16x9and_9x16. Use distinct filenames, because macOS is case-insensitive. - Checks: run
delivery_check.pylast, on every file. - Stills: full-res PNGs rendered by the engine, never grabbed from the compressed video.
- Style sheet / making-of: publish it as an artifact or doc: palette, type, subject sheet, source-vs-final footage pairs, a frame index, the pipeline and iteration counts.
- Report: tell the user what was verified, which lyrics you guessed, and the CU spent, summed
from this run's successful
jobs_waitrows (cuCost, logged inanalysis/jobs.md; a failed job is refunded but its row keeps acuCost);usageis project-wide and includes other work.
Quality bar
- Every word shows on time. Each sung word is visible at its onset (as a hero or in the subtitle track), and hero words peak on the onset frame.
- Integration, not decoration. Every footage moment has a graphic that reacts to it (behind via the matte, tracked to it, timed to its move, or continuing its shapes). The footage pixels are untouched.
- No static frames. Footage always plays live, and something always moves.
- One focal point per frame. Type frames the subject and never covers the face. Behind-the-subject type still reads. On portrait, every word, logo and face sits inside the safe band.
- Section variance. Mix the looks, 2D and 3D, poster slams and quiet subtitles. Never use the same type treatment on two consecutive lines. Cut density climbs with the song's energy, and showcase moments (logo, end card) get time.
- Photosensitivity. At most 3 full-frame flashes per second, end card included (WCAG flashes: pairs of opposing luminance changes).
- Watch it yourself before calling it done, then take a second look at the first 3 seconds.
Files in this skill
- Setup and analysis: scaffold.sh, audio_analysis.py, lyrics_align.py, plot_lyrics.py
- Locked npm dependencies scaffold.sh copies into new projects: package.json, package-lock.json
- Hashed, wheels-only Python locks scaffold.sh installs, one per platform: macos-arm64.txt, linux-x86_64.txt, resolved from requirements.in
- Approved-master stem lookup for transcription, plots and vocal slices: audio_paths.py
- Footage generation helpers: synth_beat.py, beatwarp.py
- Footage prep: prep_clip.sh, prep_video.py, matte.swift, fixmatte.py, matte_keyed.py, matte_fallback.py, track.py
- Sync checks: lipsync_check.py, dance_sync_check.py, av_sync_check.py
- Dynamism: dynamism_check.py, rectify_screen.py (flattens a phone-filmed screen), references/dynamism.md
- Rendering and review: render.mjs, render_lib.mjs, still.mjs, serve.mjs, sheet.py, delivery_check.py
- Engine, copied by scaffold.sh: index.html, main.js, blur.js, canvas.js, core.js, plate.js, roto.js, typekit.js, hud.js, plus timeline.template.js and scene.template.js
- references/pipeline.md: every command and Scenario call, step by step
- references/engine_api.md: the scene contract and the full
EAPI (canvas and safe band, plates, mattes, tracking, post, HUD, variants) - references/motion_library.md: looks, type system, 40 techniques, integration ideas, transitions, timing, easing, sync and cut density
- references/agent_brief_template.md: the brief each scene agent reads
- references/lessons.md: production gotchas and direction defaults that held
Files (skills)
-
assets
-
engine
-
scenes
-
hud.js 8.7 KB
Loading…
-
-
blur.js 7.7 KB
Loading… -
canvas.js 4.2 KB
Loading… -
core.js 15.9 KB
Loading… -
index.html 2.5 KB · in bundle
-
main.js 23.2 KB
Loading… -
plate.js 5.4 KB
Loading… -
roto.js 9 KB
Loading… -
typekit.js 8.1 KB
Loading…
-
-
npm
-
package-lock.json 2.6 KB
Loading… -
package.json 198 B
Loading…
-
-
python
-
linux-x86_64.txt 160.4 KB
Loading… -
macos-arm64.txt 154.9 KB
Loading… -
requirements.in 543 B · in bundle
-
-
scene.template.js 5.2 KB
Loading… -
timeline.template.js 3.6 KB
Loading…
-
-
references
-
agent_brief_template.md 7.7 KB
Loading… -
audio_editing.md 6.4 KB
Loading… -
dynamism.md 11.8 KB
Loading… -
engine_api.md 23.1 KB
Loading… -
lessons.md 12.6 KB
Loading… -
motion_library.md 22.1 KB
Loading… -
pipeline.md 25.3 KB
Loading…
-
-
scripts
-
audio_analysis.py 4 KB
Loading… -
audio_paths.py 502 B
Loading… -
av_sync_check.py 2.3 KB
Loading… -
beatwarp.py 1.9 KB
Loading… -
dance_sync_check.py 1.5 KB
Loading… -
delivery_check.py 7.1 KB
Loading… -
dynamism_check.py 38 KB
Loading… -
fixmatte.py 1.6 KB
Loading… -
lipsync_check.py 2 KB
Loading… -
lyrics_align.py 7.2 KB
Loading… -
matte.swift 2 KB · in bundle
-
matte_fallback.py 1.1 KB
Loading… -
matte_keyed.py 2.3 KB
Loading… -
plot_lyrics.py 1.9 KB
Loading… -
prep_clip.sh 1.6 KB
Loading… -
prep_video.py 2.5 KB
Loading… -
rectify_screen.py 13.2 KB
Loading… -
render.mjs 7.2 KB · in bundle
-
render_lib.mjs 6.1 KB · in bundle
-
scaffold.sh 6.2 KB
Loading… -
serve.mjs 2 KB · in bundle
-
sheet.py 1.3 KB
Loading… -
still.mjs 3.5 KB · in bundle
-
synth_beat.py 2 KB
Loading… -
track.py 1.8 KB
Loading…
-
-
README.md 21.3 KB
# scenario-kinetic-music-video (maintainer notes, not packaged) ## Origin Sara Nemati own `kinetic-music-video` skill, built from the production of the Every Scenario music video (and the kinetic music video it grew out of) and rewritten to be generic: any subject or none, any looks, no project examples. Brought into this repository from the ZIP she exported on 2026-10-02. ## Edits for this repository - Frontmatter reduced to `name`, `description` ("Use when", under 500 characters) and `license`; the name carries the `scenario-` prefix. - Generative model names and ids removed (availability differs per team): lanes are named by capability and found with `recommend`. Parameter names are the ones that held at authoring time, with the schema as the authority. - Credit amounts stated as relative costs, with `dry_run` before paid steps. - En and em dashes replaced, scripts print usage when called without arguments, and the output-writing scripts refuse to replace an existing file without `--force`. - Sibling references and the install invitation added; connection setup points to `scenario`. ## Portrait canvas Added after import so the skill can serve vertical feeds. One canvas per project (`CANVAS` in the timeline), with `--canvas` for a second ratio. `assets/engine/canvas.js` holds the presets, the 9:16 safe band (derived from the band `scenario-formats` and `scenario-video-ads` compose to, reading their 6 to 13% per side as 6% left and 13% right, where the action rail sits), the per-canvas timeline filter and `plateFit`. The HUD, the house subtitle and the scene template lay out inside `E.SAFE`; every portrait-only behavior is gated off landscape. Verified headless (Playwright's Chromium, software WebGL) with synthetic audio, lyrics and a synthetic footage clip (frames, matte, tracking): landscape stills of both template branches (footage and 3D) and the HUD, including a 150-character lyric line, are pixel-identical to the pre-change engine at scales 1 and 0.5. Portrait and square stills were checked by eye with the safe band outlined, and the error paths (bad canvas, bad timeline tag, an `--only` with nothing to render) fail fast. `canvas.js` has a unit suite. Two plan-only application tests (portrait only; both ratios) passed with notes. A live application test then produced a full 1080p60 portrait video end to end (a 2:14 song, 24 style frames, 27 clips, 9 section agents, about 15k CU) and passed with notes. It found the portrait subtitle running into the HUD counters, a `crop` that stretched plates, a `--chant` window with no end, transcription passes overwriting each other, `still.mjs` keeping a stale sheet, and the doc gaps behind a mic-covered lip-sync retake, the 720p-only cost anchors and a rejected reference crop. All are fixed; `motion_library.md` §10 notes one production behind its portrait rules. ## Dynamism gate Added so a render is held to numbers per section, not to an eye that adapts after a few watches. `scripts/dynamism_check.py` gates a render and measures references; `scripts/rectify_screen.py` flattens a phone-filmed screen first, since a reference often arrives as a phone filming a TV or a laptop, and motion read off that raw video measures the hand. How the measurement was chosen, all on synthetic clips encoded with libx264: - **A 60 fps clock and distinct frames.** Each picture of 24 fps footage repeats 2 or 3 times in a 60 fps render, so frame-to-frame differences read a live clip as mostly still. A first design compared frames 0.1 s apart. It fixed the repeats, but its flow saturated near 12 px per frame and then fell as speed rose: pans at 18 to 96 px per frame all read 4 to 6. A 1-frame toggle or a 3-frame shake also compared identical phases and read fully still. The script now runs optical flow between consecutive distinct frames, skips repeats, and averages 0.5 s windows (whole 24, 25 and 30 fps cycles). - **Flow range.** OpenCV's dense flow pyramid stops at 32 rows, which capped it near 16 px at the 320 px analysis size. A 1/8-size pass seeds it, and a whole-frame shift catches whip pans beyond that. Constant pans from 3 to 192 px per frame read strictly increasing, within 7% of true at native 60 fps and within 8% as 24 fps footage. - **Still runs at frame resolution.** Fixed 0.1 s steps read a 0.60 s hold as 0.5 s, which passed the high limit. Runs now end on the frame, and a 0.60 s hold reads 0.60 s. The still test uses a gray difference of 12, not 24: at 24, a 6 px per frame pan of 24 fps footage over soft texture read 44% still. - **Slow moves add up.** A still run first ended only on per-pair flow of 1 px or a pixel change. Sub-pixel drifts at the calm (0.5) and mid (1.0) motion floors then split into short runs that all read 100% still, and a 10% push-in over 2 s read 97% still. A run now also ends once the flow from its first frame reaches 0.25 px at 320. - The limit was 0.4 first. 24 or 25 fps footage shows only 2 new pictures in a 0.1 s run, about 0.4 px at the calm floor, so a calm drift and a 10% push-in read 12 to 93% still there. - At 0.25, both read 0% still at 15, 23.976, 24, 25, 29.97, 30 and 60 fps drawn at twice the analysis size, and at 24, 25 and 60 fps rendered at 1920 x 1080. Drawn at 320 itself, a drift still read up to 23% still at 24 and 25 fps (53% at 15): libx264 holds some of its sub-pixel steps. - Gaussian grain of sigma 1 to 3 gray levels on a hold measured 0.01 to 0.17 px from the run's first frame and reads 100% still. CRF 23 smooths grain past the pixel test: there, sigma 3.4 to 4 read 70 to 100% still at 0.25, and sigma 3.4 only 70 to 83% at 0.2, so the limit stops at 0.25. At CRF 12, the pixel test breaks a hold from sigma 3.8, as before. - That flow call runs only once the per-pair steps since the run began sum to half the limit, so a clean hold or a fast move never pays for it. - **Decoded size.** ffprobe reports a phone clip's coded size, before its rotation tag. A portrait clip stored landscape read as a landscape canvas, with 45% less motion. The size now comes from a decoded frame, as in `rectify_screen.py`. - **A flash is one cut.** Cut frames within 3 frames of each other merged, so a white flash of 4 or more frames (2 in a 30 fps preview) read as two cuts. A cut back to the previous shot within 0.15 s now ends the same cut; a strobe counts one cut per flash. - **Flashes follow WCAG 2.x general flashes:** a pair of opposing changes of 10% relative luminance, the darker state under 0.80, on the frame mean, at most 3 per second everywhere. Counting each change as a flip would have failed a white flash on every beat at 120 BPM; the pair reading allows it and still fails full-frame 8ths. - **Speed.** Flow runs on every distinct pair, in 4 threads. A 10 s 1080p60 test pattern measured in about 1 s (3 s on one thread) on an M-series Mac at authoring time. Default targets are uncalibrated: they were checked on synthetic fixtures only, never on a real render. Calm allows a 1.0 s hold, not more, because the quality bar says no static frames. Calibration is pre-registered for the next live `/skills:validate` run, which gates every section of its render: - An approved section that fails: loosen that energy's default to its measured value with the `--write-targets` margins (still + 0.10, hold × 1.25, motion × 0.7). - A section the grader calls static that passes: tighten that energy's default to its measured value. - Approved sections pass and static ones fail: keep the defaults, and drop the "uncalibrated" hedge once a second production agrees. - A flash failure is never loosened: the limit is a safety rule, not taste. `rectify_screen.py` on a synthetic handheld clip (zoom 3%, drift 14 x 9 px, a caption band): - manual corners: mean error 1.3 of 255 against the true screen content; - auto detection: corners within 5 px, error 2.8 of 255, 100% of frames tracked; - median motion: 4.7 on the true content, 6.5 off the flattened screen, 1.4 off the raw phone clip. Known limits: - The numbers are frame-wide. Frozen footage under moving type passes, and a lip-sync close-up where only the mouth moves reads still; `freezedetect`, the contact sheets and dynamism.md §7 cover them. - Flashes on part of the frame are not measured. - Auto screen detection needs a screen brighter than the room. A live `/skills:validate` run filmed black bars around a vertical video: the room outscored the screen, and its outline filled the frame. Such an outline now exits "no screen found", after writing the `--check` frame. Quadding the video itself tracked 100% of frames. - The same clip inside black bars (a landscape recording posted as a vertical video) outlined the whole recording and failed on texture, with no `--quad` hint. Detection now crops the bars first, and the clip exits "no screen found" as it does without them. - `--write-targets` takes span energies as given. Labeling spans by how busy they look once held a calm section to more motion than a mid one, so `measure` warns when targets run out of order. It checks the targets the gate will use: a calm-and-high file still meets the default mid. - Sections come from `node` evaluating `engine/timeline.js` as a `data:` URL module. A timeline with relative imports falls back to a file URL, which needs a Node that detects ES modules in the project's typeless `package.json` (20.19+ or 22.7+). - `scaffold.sh` copies the scripts into `tools/` on every run, but its `cp -n` keeps an existing project's `ENGINE_API.md` and `AGENTS_BRIEF.md`, and rerunning it reinstalls the environment. So SKILL.md step 6 tells a revision of an older project what to copy by hand: the brief is filled in per project, so only its dynamism check is added. ## 4K master `--scale 2` reuses the canvas: layouts already scale with `E.SCALE`. Three things did not, and each fix applies above scale 1 only, so the shader text and the encoder arguments at scale 1 or below are unchanged. - **Bloom:** UnrealBloomPass blurs in texels of its own targets, so at 4K the glow reached half as far. It now runs at the scale-1 size. Its bright pass then read only the middle of each 4×4 block, so it averages the block with four bilinear taps instead: without them, thin lines pulse as they move. - The engine supplies that bright pass whole instead of patching three's shader text, which a reformatting release would break with no CI test to notice (the repository installs no three). It relies only on the uniforms UnrealBloomPass feeds, and boot refuses `--scale` above 1 if one goes missing. Seven 4K stills match the text-patched version byte for byte. - **Grain and scanlines** keep 1080p cells (string substitution in the final shader). - **Encoder:** above 1080p, `-level` from H.264 Table A-1, a VBV cap from that level, and `-threads 4`; `render.mjs` caps the workers to memory and refuses a 4K master past Level 5.2. - CRF alone has no ceiling. On a real project with grain 0.06 over footage, 3 s of 4K60 at CRF 17 peaked at 296.6 Mb/s in its busiest second, against the 300 Mb/s Level 5.2 High allows. - The cap is the level's Main MaxBR (80% of the High limit) with a buffer of a quarter of it, so no second inside a chunk passes the High limit. The same 3 s then peaked at 262.2 Mb/s (252.7 average), at 41.5 dB against the uncapped file. Evidence (an M-series Mac, ANGLE Metal, three 0.186.1, ffmpeg 7.1.1, a synthetic project with a footage plate, matte and tracking, 2D and 3D type, grain, scanlines and the HUD): - **Unchanged at scale 1 or below:** stills of every frame at scales 0.5 and 1, plus square and portrait, are pixel-identical to the previous engine. Four `render.mjs` files (960×540 at 30 fps on 2 workers, 1920×1080 at 60, 540×540 at 30, 1080×1920 at 60) are byte-identical. - Chrome's GPU canvas rasterizes large or scaled glyph edges with ±1 differences from run to run, in the old engine as in the new. The comparison runs with `--disable-accelerated-2d-canvas` (3 of 3 repeat runs identical), so a difference can only come from the engine. - **Moving thin lines** (0.5 to 1.5 px wide, half a 1080p pixel per frame), per-frame halo energy against 1080p: within 0.6% with the fix, up to 148% off with the bloom resized alone, 129% off with no fix. Area-downscaled PSNR against 1080p: 39.3, 27.9 and 24.2 dB. - **Grain:** 4K grain is constant over 2×2 cells and correlates 0.79 with the 1080p pattern (−0.04 before), the rest being 8-bit rounding near black. - **Levels:** `h264Level` matched x264 medium's own pick in 30 cases from 176×144 to 5120×2880, so the pin changes no bytes at 4K60; a vitest case reruns that on CI's ffmpeg. With `-preset slow`, x264 signals 5.0 at 1080p60 on its own; `-level 4.2` makes it drop to 4 reference frames. - **Cost:** a 4K frame took 3.3 times as long. Peak footprint per worker (Chrome, its GPU process and x264) was 2.5 GB at 1080p and 5.3 GB at 4K; `workerGB` adds about a gigabyte for real footage caches. - **three 0.187.0**, which main moved to while this work was open, on 2026-11-07: the bloom, composer and shader addons are byte-identical to 0.186.1. On a real project with footage, mattes, 3D type, bloom, grain and scanlines, 9 stills at scales 1 and 2, and 3 with blur, are byte-identical on both versions; at 0.5, one pixel of one still differs by one level. Repeat runs were identical on each version. - **Older project:** on a project made before the portrait canvas, the `pipeline.md` §7 copy without `canvas.js` crashed the page, since `main.js` imports it. With it, a landscape still matched the old engine at 48 dB. The same project's 4K stills showed the per-section check working: its `THREE.LineSegments` edges stay one device pixel wide, so they glowed less than at 1080p. ## Motion blur In-engine GPU accumulation, opt-in per project (`BLUR` in timeline.js). - **Design:** `renderTime` keeps the frame pass as it was. When `blur.js` plans sample times, the blurred layers render again at each, every composite is added into a float32 target, and the sum divided by n replaces the frame's composite before bloom and the final shader, which run once. `render.mjs` still grabs one JPEG per frame. - Exact for static content: each composite is half-float, a sum of up to 24 equal half values is exact in float32, and dividing by n restores the value. - Sharp layers (`blur: false`, the HUD) keep the frame pass's render target in every sample. Every blend mode is linear in the layer below, so this is exact too. - The shutter opens at the frame time, so nothing shows before its onset. A cut inside it slides it back, never before the previous cut. - Cuts: entry bounds, `E.cut`, and word switches (`w.s - LEAD`). Without them, a hero word swapped on its onset showed both words in one frame of the fixture. Beats are opt-in: a cut per beat shifts the streak on about one frame per beat. - `trackAt` replays the frame pass by call order, per layer. Recomputing from the sample time crosses clip frames; matching by clip time first picked the wrong call when a clamped label's time coincided with a slow-motion one (a `blur.test.ts` case pins it). One order across layers let a sharp layer's calls, or `prepare()`'s, shift a blurred layer onto another call's landmark (`core.test.ts` cases pin both). - A sample drawing a clip that `prepare()` did not advance (an undeclared switch inside a scene) makes the frame fall back to its frame pass, copied aside before the samples. - Without `EXT_float_blend` the sum ping-pongs between two float targets, bit-identical to blending. - Off by default: existing projects render unchanged, 8 samples cost about 2.2 to 2.5 times the render time, and the director approves the look on sharp previews. - **Default samples, 4 against 8:** type moving 2400 px/s and a box spinning 9 rad/s, 180° at 60 fps, against 64 samples on the moving band. 4 samples: 34.9 dB mean, 31.0 worst, with visible copies on the type. 8: 41.5 and 37.7. 12: 45.6 and 41.9. No blur: 21.0. Frame time with the PNG grab: 79 ms without blur, 122 at 4, 195 at 8, 265 at 12. Hence 8, with `E.fast` for slams. - **Byte-identity protocol** (headless Chrome, ANGLE Metal, `--disable-accelerated-2d-canvas`, the synthetic project of the 4K evidence above): - Blur off: every frame of the 6 s project at scales 0.5 and 1, square and portrait, matches the previous engine, and the four `render.mjs` files are byte-identical. - Static content with blur on: 90 of 90 frames identical to blur off at 1080p and 5 of 5 at 4K, with float blending and with the ping-pong path; SwiftShader the same on 3 frames. - Labels tracked at clip time t, t/2 and a clamp: 180 of 180 frames identical with 8 samples; 32 differ without the replay. - An undeclared clip switch: that frame comes out identical to blur off and `render.mjs` lists it; with `E.cut`, it blurs and its plate matches blur off. - A scene throwing inside a sample: the frame state comes back, and the next frame matches a clean run. - To rerun it, render frames through `window.renderFrame` with the old and the new engine and compare hashes; the vitest suites cover the planning, not the pixels. - **Not covered:** camera moves made with `E.post` (punch, shake, rot) stay sharp, and roto materials or custom textures are not checked for stale clips. ## What the record does not cover - The skill is the creator's own document, not distilled here, so it does not follow the house layout for recipe skills: its `references/lessons.md` plays the Common mistakes role. - Costs are the production's observed relative prices, not live quotes. - The engine and scripts need Node with Playwright, ffmpeg and a Python environment (`scripts/scaffold.sh` builds it); the matte tool needs macOS (Apple Vision). - Tests cover the dependency-light scripts, the dynamism and rectify scripts on synthetic clips, `canvas.js`, `blur.js`, the clip and tracking logic in `core.js`, `render_lib.mjs` and `delivery_check.py`; the rest need the full environment and generated footage. - The 4K path and motion blur were checked on synthetic projects only, not yet in a live application test. ## Supply chain What the setup and analysis scripts fetch, and how each source is pinned: - **npm**: exact direct versions and a v3 lock with integrity hashes, installed with `npm ci --ignore-scripts`. - **Python**: `assets/python/<platform>.txt` pins every package, transitives included, by version and SHA-256, wheels only. Installing builds nothing, so no build backend or compiler toolchain is fetched. Each run rebuilds `.venv` from the lock alone, with no `ensurepip`, so no unlocked pip. Only macOS arm64 and Linux x86_64 (manylinux 2.28, so glibc 2.28+) have locks: on Linux aarch64, `demucs` needs `sphn`, which has no wheel there, and its source build fetched a Rust toolchain and failed. - **beat-this**: PyPI 1.1.0. Its provenance attestation names CPJKU/beat_this commit `ad7974846029835307ba19a3d5cefbf40b243041` (tag v1.1.0), and the wheel's package files are identical to that commit. uv refuses a Git requirement in hash-checking mode, so the attested wheel is how the commit is pinned. - **Fonts**: google/fonts at one commit. Each file the scaffold downloads, and its family's `OFL.txt`, is checked against SHA-256. A mismatch removes the download and stops the scaffold. Files already in `assets/fonts/` are kept as they are, unchecked. - **beat_this checkpoint**: `audio_analysis.py` downloads `final0` once into `models/`, checks its SHA-256 on every run, and passes the local path, which beat_this loads with `weights_only`. Given only the name, beat_this would fetch it unverified and unpickle it. - **Whisper**: `lyrics_align.py` loads `Systran/faster-whisper-large-v3` at a fixed Hugging Face commit. Regenerate the locks after any change to `requirements.in`, with uv 0.13.0: run the command in each lock's header, moving `--exclude-newer` to the date you resolve on. The offline checks in `tests/scenario-kinetic-music-video/test_python_lock.py` run in `pnpm test`. `.github/workflows/kinetic-locks.yml` re-resolves both Python locks to prove they reproduce, then installs each on its platform and imports the tools' modules. It also installs the npm lock with `npm ci --ignore-scripts` and imports its three packages. Verified on 2026-10-29, with no Scenario calls: - The real scaffold ran in a `node:22-bookworm` container (linux/amd64, uv 0.13.0) and natively on macOS arm64: fonts, licenses, `npm ci`, the hashed Python install, every import, and `audio_analysis.py` on a synthetic 120 BPM click track (read back as 120 BPM). - A tampered checkpoint was rejected and removed. The test suites cover a tampered font. - The scaffold's test suite checks the platform choice, the hashed wheels-only install, and that a font mismatch installs nothing. Remaining gaps: - `uv venv --python 3.11` downloads a managed CPython when none is installed. uv verifies it against checksums built into uv, but uv itself, Node, npm, ffmpeg, Chrome, and swiftc are the user's. - Demucs downloads `htdemucs` weights from `dl.fbaipublicfiles.com`, checked only against the short hash prefix in the file name, then unpickles them. - The Whisper commit pins which files are fetched; whether huggingface_hub verifies their content was not checked. - MediaPipe's legacy solutions ship their models inside the hashed wheel; nothing else downloads at run time as far as the scripts show. -
SKILL.md 18.1 KB
--- name: scenario-kinetic-music-video description: "Use when turning a song into a kinetic-typography or motion-design music video, lyric video, visualizer or K-pop style MV with Scenario, landscape or vertical 9:16 for TikTok, Reels and Shorts: a generated subject sheet, style frames and footage, plus a deterministic JavaScript/three.js engine for lyric type, mattes and tracked graphics timed to sung onsets. Also for revising, recutting or cutting teasers from such a video. Not for a brief-led launch film (scenario-kinetic-film)." license: MIT --- # Kinetic Music Video A song goes in. A 1080p60 music video comes out, landscape for YouTube and X or vertical for TikTok, Reels and Shorts: a motion designer's showreel cut to the track. Kinetic type, 2D and 3D graphics and transitions land on the beats and sung syllables. Generated footage of the subject is woven through it where the concept wants a performer. The approved master is the only soundtrack. Preserve the original; an authorized audio edit produces a new, versioned master. The work splits by what each tool does best: - **Scenario** supplies what code can't: a consistent subject with real physics, choreography, hair and lip-sync, in whatever art style each section needs. - **The JS engine** supplies what video models can't: exact typography, frame-exact timing to onsets and beats, infographics, compositing around the subject, and endless re-renders at zero generation cost. - **Sub-agents** give each section a dedicated designer. A shared style bible and a verification loop keep them coherent. Connection and the core generation loop: see the `scenario` skill in this repo. For a song-to-video cut without the engine, see `scenario-seedance-music-video`. If a sibling skill named here is missing from your available skills, load it with `skill_get` (Scenario MCP) or ask the user to install it (https://github.com/scenario-labs/skills#install); unattended, proceed from tool schemas and flag the gap. Read `references/lessons.md` before starting. Every item in it cost real time or money once. `references/motion_library.md` is the design menu. ## Before you start (ask once, then run) - **Workspace:** the Scenario team and project (`teams_list`; ask if there is more than one). - **Subject:** - Who or what performs: a character from reference images, a mascot, a product, the artist's own likeness (their own photos and consent only), or nobody (a pure motion-graphics or lyric video). - Footage share: performer-led, a mix (often about 60/40), or graphics only. - **Look:** - Ask for references: images, videos or links for the mood, the motion and the **color**. Vague color asks without references drift to safe palettes. - Decide the 2-4 looks and which sections own which. - Ask what must never appear. - Defaults: generated footage shown clean (no filters on it), graphics layered on and around it, a fast and upbeat showreel energy. - **Brand:** any logo, wordmark or credit. Use official files in their official colors, only where the director wants them. - **Budget:** lean (6-10 video generations), moderate (12-20) or big. Price each paid step with `dry_run` (one run per distinct payload, then total) before spending. Relative anchors at 720p: a 6 s clip costs about twenty style frames, a 10 s clip about thirty-five, and a full mixed video about five hundred. A 1080p clip measured about 2.5 times its 720p price, so settle the footage resolution before quoting. - **Format:** one canvas per project, asked once: portrait 9:16 for TikTok, Reels or Shorts, landscape 16:9 for YouTube or X (unattended with no destination: landscape). It is `CANVAS` in `engine/timeline.js`, and style frames and footage are generated at that ratio, never cropped from the other. On portrait, check the destination's current length cap and plan the teaser as the platform cut when the song runs longer, or when you cannot check. Both ratios only on request: the code re-renders free with `--canvas` and most shots are windowed, but each shot that must fill the second frame (hook, lip-sync close-ups, finale) is paid again (`references/pipeline.md` §9). X caps standard accounts at 2:20, so plan a teaser. - **Lyrics:** use them if supplied (they beat any transcript). Otherwise transcribe and flag the uncertain words at the end. With no one around to answer, choose sensible defaults for the creative choices and write them into TREATMENT.md. Do not default the money: with no stated budget or no explicit team and project, stop before the first paid step and say what is missing. ## Workflow ### 1. Scaffold and analyze the song Run `bash <skill>/scripts/scaffold.sh <song>` inside a new project folder (macOS on Apple Silicon or Linux x86_64 with glibc 2.28+: the Python lock covers those two), then follow `references/pipeline.md` §2: - `audio_analysis.py` writes stems and `engine/data/audio.json`: beats, downbeats, kick/snare/vocal onsets, and 60 fps envelopes. **Measure the tempo**; labels lie (a "130 BPM" song was 98 with double-time drums). - `lyrics_align.py transcribe`, then hand-correct `analysis/lyrics.txt`, then `lyrics_align.py align` writes `engine/data/lyrics.json` with word onsets. - Check timing by eye with `plot_lyrics.py`. Audition when playback is available; a spectrogram locates onsets but cannot prove pronunciation or musical continuity. ### 1a. Edit the soundtrack when requested For pronunciation repairs, lyric changes, section replacements or structural cuts, read [references/audio_editing.md](references/audio_editing.md). Use `scenario-ace-step` for its Cover/Repaint contracts. Keep the current cut and master until a candidate is selected; preserve audio outside the agreed window and rebuild affected timing data after applying it. A picture-only revision reuses the approved soundtrack. ### 2. Research (parallel, background) Launch two sub-agents with web access while you work on other things: - **Culture:** for the song's subject, find recognizable events, memes and visual tropes, each with a verified fact, its iconic visual form, an insert idea and a short on-screen string. - **Craft:** study the user's motion references (download them, contact-sheet them, read the frames), plus genre direction techniques. Extract timing numbers, color hex values and implementable JS moves. Measure each reference per section into `analysis/targets.json` ([references/dynamism.md](references/dynamism.md) §5). Save the condensed results as `analysis/research_*.md`. Scene agents read them alongside `references/motion_library.md`. ### 3. Concept, style bible and treatment - **Give the video a spine.** The strongest concepts make the edit itself carry the song's meaning: a device that progresses through the whole video, for example a counter, clock or countdown that moves with the song while the cut rate or the looks escalate with it. The spine usually lives in the HUD counters. - **STYLE.md** (the law): - a one-line concept and the spine - the footage rules (clean plate and the back/mid/front layers, or another policy) - the looks, each with ground, ink, accent, rendering rule and matching footage style - the palette with roles - 4-5 type roles with named fonts - lyric display rules - a motion grammar mapping beats to effects, with the cut density per section - the subject (identity, design details usable as graphic motifs) - brand rules, references and bans - **TREATMENT.md:** - song facts and the energy map - the arc - the **hook for the first 3 seconds** (the strongest idea in the video, and it must work as a muted autoplay) - one row per section: time range on downbeats, lyrics, look, must-have ideas - a footage map (filled in as clips land) - **PLAN.md:** a one-page version for the director to approve before you spend on footage (unattended, this is the stop point if the budget is unstated). ### 4. Subject, style frames and footage on Scenario Skip this for a graphics-only video, apart from any stills or 3D props. Otherwise follow `references/pipeline.md` §3-5: - **Subject sheet:** a turnaround, expressions and callouts from the user's references. Look at it, then crop identity references from it. - **Style frames:** one still per shot at the canvas ratio (an image model that takes reference images), in its section's look. Compose with negative space for type (on portrait, the face and the type space inside the safe band), on a set that composites (black void with rim light, flat color cyc, or white high-key). No text. In a lip-sync frame nothing covers the mouth (no mic, hand or prop): a covered mouth fails the sync check and is paid again. Contact-sheet them and get the look approved cheaply (unattended: proceed only inside a stated budget). - **Footage routes:** - Image-to-video from the frame for actions. - A video model with reference images and reference audio, given a **synthesized beat track** for dances that lock to the song, then beat-warp. - **Audio-to-video** from a frame plus a vocal-stem slice for lip-sync. The alternative is reference-audio video plus a lip-sync correction model. - Code instead of generation for networks, charts, UI and particles. - Never send the song to a video model. Turn the model's native audio off when its schema offers it (the render takes sound only from the master either way), and launch in waves within the team's concurrency ceiling (`jobs_wait` re-called with `pending_job_ids`, never `job_get`). Relaunch only a launch refused with 429 `parallel-custom-jobs`: it created no job, and dropping it leaves a hole in the cut. - **Prep** every clip with `tools/prep_clip.sh`: frames, a subject matte (Apple Vision, with Scenario background removal as the fallback; see `references/pipeline.md` §5) and tracking (MediaPipe pose plus the matte bbox). Inspect the mattes. Write each clip's content, key moments, slot and matte quality into the footage map. ### 5. Engine and scene agents - **Smoke-test first:** - Set `PAL` in `core.js`, and in `engine/timeline.js` set `CANVAS`, the sections on downbeats with their `energy`, `HUD` (title, mark, section codes, spine counters) and `POST` (neutral by default). - Write a tiny `_smoke.js`: plate → type behind the subject → matte → tracked label. - Render one still and a 5 s clip, then confirm audio and flashes line up with `av_sync_check.py`. - **Brief the agents.** Fill in `AGENTS_BRIEF.md` from the template, then launch one background agent per section in a single message. Each gets its file, time range, lyrics, must-have ideas and clips, and reads AGENTS_BRIEF, STYLE, TREATMENT, ENGINE_API and the research first. Log the agent ids. For a teaser or anything under about 30 s, the lead may write the scenes itself and skip the research agents, PLAN.md and the per-section agents; keep the smoke test. - **Deliver clips as they land.** Message the agent that needs each one ("clip ready: content, key moments, slot"). - **Review every report.** Contact-sheet the best stills and Read them. Fix engine-level problems yourself (they affect everyone) and tell the agents what changed. ### 6. Assemble, watch, iterate - **Render the full cut** (3 workers, about 5 min for 2:00 on an M-series Mac, 2.5 times that with motion blur). Wait for it in the foreground (or poll until it prints `wrote`), then verify and deliver: never end the run mid-render or mid-encode, since a headless session that stops kills it. - **Verify:** - `av_sync_check.py`: expect 0.0 ms audio and 0 to +1 frame visual. Below a correlation of about 0.15 the visual lag means nothing (type leading by `E.LEAD` reads as up to -3 frames): check onset stills instead. - `dynamism_check.py gate` on each delivered render: exit 0. On exit 1, fix and re-gate (`--force` replaces its JSON); unattended, after 3 rounds on a section or at the budget, deliver and report the failing sections. - `freezedetect`: no frozen footage. - Contact sheets at 0.5 s steps, 20 s per sheet. - Every section boundary, frame by frame. - On portrait, `still.mjs --safe` sheets, 20 s each: no word, logo or face outside the outlined band. - **Global look pass:** a still sheet across all sections, then tune `POST`, the palette and the HUD theme. Decide motion blur from an A/B of the fastest 5 s (`--blur`, `references/pipeline.md` §7; unattended: off unless the user asked for it, then judge the pair yourself). - **Revisions:** map each director note (they arrive as timestamps) to its section and send it back to the owning agent via SendMessage. Resuming keeps its context. Fix a weak shot by replacing it with a new generation in a different look, or with code, never by adding effects. Offer alternatives as timeline `variant`s (render with `--variant b`) instead of guessing. - **Older projects:** without `tools/dynamism_check.py`, copy it and `rectify_screen.py` from `<skill>/scripts/` into `tools/`, and add the template's dynamism check to `AGENTS_BRIEF.md`. Replace `ENGINE_API.md` with `references/engine_api.md` only when `engine/canvas.js` exists; otherwise add its `energy` line. Then tag each `TIMELINE` entry's `energy` from TREATMENT.md (`references/dynamism.md` §2). ### 7. Deliver - **4K master:** only on request (`--scale 2`, `references/pipeline.md` §8), rendered first: every other file is made from it. - **Videos:** a master, an upload file (landscape: the master for YouTube, an X-ready file under 512 MB; portrait: the vertical upload in `references/pipeline.md` §8), a teaser (verse plus first chorus), plus one file per variant. With both canvases asked for, one set per canvas, suffixed `_16x9` and `_9x16`. Use distinct filenames, because macOS is case-insensitive. - **Checks:** run `delivery_check.py` last, on every file. - **Stills:** full-res PNGs rendered by the engine, never grabbed from the compressed video. - **Style sheet / making-of:** publish it as an artifact or doc: palette, type, subject sheet, source-vs-final footage pairs, a frame index, the pipeline and iteration counts. - **Report:** tell the user what was verified, which lyrics you guessed, and the CU spent, summed from this run's successful `jobs_wait` rows (`cuCost`, logged in `analysis/jobs.md`; a failed job is refunded but its row keeps a `cuCost`); `usage` is project-wide and includes other work. ## Quality bar - **Every word shows on time.** Each sung word is visible at its onset (as a hero or in the subtitle track), and hero words peak on the onset frame. - **Integration, not decoration.** Every footage moment has a graphic that reacts to it (behind via the matte, tracked to it, timed to its move, or continuing its shapes). The footage pixels are untouched. - **No static frames.** Footage always plays live, and something always moves. - **One focal point per frame.** Type frames the subject and never covers the face. Behind-the-subject type still reads. On portrait, every word, logo and face sits inside the safe band. - **Section variance.** Mix the looks, 2D and 3D, poster slams and quiet subtitles. Never use the same type treatment on two consecutive lines. Cut density climbs with the song's energy, and showcase moments (logo, end card) get time. - **Photosensitivity.** At most 3 full-frame flashes per second, end card included (WCAG flashes: pairs of opposing luminance changes). - **Watch it yourself** before calling it done, then take a second look at the first 3 seconds. ## Files in this skill - Setup and analysis: [scaffold.sh](scripts/scaffold.sh), [audio_analysis.py](scripts/audio_analysis.py), [lyrics_align.py](scripts/lyrics_align.py), [plot_lyrics.py](scripts/plot_lyrics.py) - Locked npm dependencies scaffold.sh copies into new projects: [package.json](assets/npm/package.json), [package-lock.json](assets/npm/package-lock.json) - Hashed, wheels-only Python locks scaffold.sh installs, one per platform: [macos-arm64.txt](assets/python/macos-arm64.txt), [linux-x86_64.txt](assets/python/linux-x86_64.txt), resolved from [requirements.in](assets/python/requirements.in) - Approved-master stem lookup for transcription, plots and vocal slices: [audio_paths.py](scripts/audio_paths.py) - Footage generation helpers: [synth_beat.py](scripts/synth_beat.py), [beatwarp.py](scripts/beatwarp.py) - Footage prep: [prep_clip.sh](scripts/prep_clip.sh), [prep_video.py](scripts/prep_video.py), [matte.swift](scripts/matte.swift), [fixmatte.py](scripts/fixmatte.py), [matte_keyed.py](scripts/matte_keyed.py), [matte_fallback.py](scripts/matte_fallback.py), [track.py](scripts/track.py) - Sync checks: [lipsync_check.py](scripts/lipsync_check.py), [dance_sync_check.py](scripts/dance_sync_check.py), [av_sync_check.py](scripts/av_sync_check.py) - Dynamism: [dynamism_check.py](scripts/dynamism_check.py), [rectify_screen.py](scripts/rectify_screen.py) (flattens a phone-filmed screen), [references/dynamism.md](references/dynamism.md) - Rendering and review: [render.mjs](scripts/render.mjs), [render_lib.mjs](scripts/render_lib.mjs), [still.mjs](scripts/still.mjs), [serve.mjs](scripts/serve.mjs), [sheet.py](scripts/sheet.py), [delivery_check.py](scripts/delivery_check.py) - Engine, copied by scaffold.sh: [index.html](assets/engine/index.html), [main.js](assets/engine/main.js), [blur.js](assets/engine/blur.js), [canvas.js](assets/engine/canvas.js), [core.js](assets/engine/core.js), [plate.js](assets/engine/plate.js), [roto.js](assets/engine/roto.js), [typekit.js](assets/engine/typekit.js), [hud.js](assets/engine/scenes/hud.js), plus [timeline.template.js](assets/timeline.template.js) and [scene.template.js](assets/scene.template.js) - [references/pipeline.md](references/pipeline.md): every command and Scenario call, step by step - [references/engine_api.md](references/engine_api.md): the scene contract and the full `E` API (canvas and safe band, plates, mattes, tracking, post, HUD, variants) - [references/motion_library.md](references/motion_library.md): looks, type system, 40 techniques, integration ideas, transitions, timing, easing, sync and cut density - [references/agent_brief_template.md](references/agent_brief_template.md): the brief each scene agent reads - [references/lessons.md](references/lessons.md): production gotchas and direction defaults that held
Reviews (0)
No reviews yet.
Comments
Sign in to join the conversation.
No comments yet. Start the conversation.