Skip to content

idea: music-video timing stack - analyze_beats, lyric/beat cut planner, pad-then-trim shots, vocal/b-roll flags #600

Closed
4 of 4 issues completed

Description

@dkackman

Idea, not approved work. Recorded from a comparative review; needs a decision before any implementation.

Gap

workflows/templates/minimax/music-video.json cuts every shot at one fixed num_frames (124), from a start_frame set by hand for each shot. transcribe_audio returns word timestamps, but nothing turns timestamps or beats into a shots list, and analyze_audio has no beat analysis.

Idea

A CPU-only timing stack for music videos, in four stages. Each stage ships on its own.

  1. analyze_beats task.
    • Beat tracking (librosa beat_track + onset_backtrack) returns beat times and BPM, with an RMS-peak fallback.
    • Calibration corrects offset and drift: either warp detected beats through a few user anchors, or build an even BPM grid from one anchor.
  2. Cut planner task (e.g. plan_cuts).
    • Takes transcript chunks plus optional reference lyrics and keeps the user's exact text and line order.
    • Segments by line, stanza or beat.
    • Options: include_instrumental_gaps with min_gap_seconds (intro, break and outro scenes), min/max scene length, a vocal tail pad, and snap_to_beats.
    • Emits shots entries (start_frame, num_frames, lyric, kind) that plug straight into for_each.
  3. Variable-length shots with pad-then-trim.
    • Render warm-up/cool-down handles, rounded up to the model grid (H3: 17n+5). Grid rounding comes from the workflow's variable_constraints, not engine code.
    • Trim video and audio back to the exact timeline range, using absolute rounded boundaries so drift does not accumulate.
    • Leading frames hide the stiff opening, and the shot ends exactly on the cut.
  4. Per-shot kind: vocal | instrumental | broll and singer.
    • B-roll and instrumental shots drop the audio conditioning, the singer references and any singing direction.
    • singer selects which cast references (one or more) a vocal shot uses, which makes duets possible.
    • The minimax-h3 skill states how to write a B-roll prompt.

Possible value

Music videos cut on the lyrics and the beat, with exact durations, instead of fixed 124-frame shots placed by hand.

Related

  • htdemucs vocal-stem separation (separate issue) improves Whisper alignment on sung lyrics.
  • The H3 audio-hold (separate issue) tightens lip sync on vocal shots.

Their files: VRGDG_MusicVideoBuilderNodes.py (beat functions around line 3367; Line Mapping), VRGDG_MiniMaxH3Timing.py, Workflows/LTX-2_Workflows/Video_Builder/readme.md.

Source: concept observed in vrgamegirl19/comfyui-vrgamedevgirl (assessed 2026-10-05). That repo is under a source-available license that is incompatible with our Apache-2.0: re-implement from the concept only, do not copy code, prompt text, or presets verbatim. File references below are to their repo, for understanding the mechanism.

Activity

  1. dkackman commented on Oct 5, 2026

    @dkackman
    OwnerAuthor

    Related: stems #604, H3 audio-hold #598.

  2. added
    owner:leadFeature lead's turn (harnest R11)
    priority:2Backlog rank: solid ROI, moderate scope
    featureWork bigger than a fix: designed with Don, built in stages (harnest R11)
    and removed
    owner:donParked for human decision
    ideaAn idea for the researcher agent to assess
    on Oct 5, 2026
  3. dkackman commented on Oct 5, 2026

    @dkackman
    OwnerAuthor

    Approved by Don (2026-10-05) at priority:2. Plan it as four stages that ship separately, with analyze_beats first. Model grid rounding stays in the workflow's variable_constraints, never in engine code. Handing to the feature lead for a plan.

  4. dkackman commented on Oct 5, 2026

    @dkackman
    OwnerAuthor

    Plan v4: music-video timing stack (#600)

    Feature lead: claude-opus-5-5 via anthropic. v1 was the design session on develop @ 21cd845, and v2 recorded Don's approval of v1. v3 is a design session on develop @ c3fc366. It folds in Don's decision on #627 (2026-10-06): no engine change, every shots entry carries all three length fields, and the three smaller gaps are closed. Only stage C changes. Stages A (#625) and B (#626) are built and verified, and they stand. v4 records Don's approval of v3 (2026-10-06): Q6 and Q7 decided as their defaults; no scope change.

    Verdict: build smaller (unchanged)

    Approved scope (Don, 2026-10-05; v3 approved 2026-10-06): stages A–C. Stage D is not approved. After stage C ships and has cut a real music video, D goes back to Don with its Q4 mechanism and with what that run showed about B-roll and per-shot singers. If C closes out first, the feature closes at C and D is filed as its own idea.

    The three cuts from the proposal stand:

    • No runtime for_each. Planning is its own run. The agent reads the cut list, writes one prompt per shot and passes the list as shots.
    • No librosa. Beats come from numpy/scipy in dw/dsp.py, and that has shipped in A.
    • No exact-audio trim on the deliverable. music-video lays the whole unbroken song back over the edit with pair_audio. (trim_video still trims a clip's own audio, so the task is correct when used alone.)

    Value

    Build cost

    • A and B are done.
    • C was about $6 and is now about $7: the slice_audio argument and its preflight, plus the snap carve-out and its test.

    Inertia

    • New tasks:
      • analyze_beats and plan_cuts have shipped.
      • Stage C adds trim_video, plus one optional lead_frames argument on slice_audio.
      • No MCP or REST route changes. Tasks don't count against the MCP surface budget.
    • Templates: music-video-cuts has shipped.
    • A new music-video entry contract: {name, prompt, start_frame, num_frames, lead_frames, cut_frames}, all required. This is a breaking-change.
      • About 20 tests and about 12 skill and doc locations pin the old shape. They are listed under stage C.
    • music-video stops snapping num_frames. It becomes the one MiniMax template that refuses an off-grid length instead of rounding it. This is deliberate: a snap would silently stretch a render under an explicit cut_frames. tests/test_variable_constraints.py:485 gains a named exception for it.
    • Security boundary: unchanged.

    Reversibility

    • trim_video and slice_audio's lead_frames are additive.
    • The entry contract is breaking-change either way. Callers that pass num_frames= get an unknown-variable refusal. Hand-written lists without the three fields are refused with the missing field named.

    Cheaper alternatives

    • Stop at A+B: see Value. You keep a cut list but get no exact lengths.
    • Q4's step-declared entry defaults in C: this would keep hand-written lists shorter. Don declined it for now, and Q4 stays open.

    Overlap

    Problem and non-goals

    Problem: cut a music video on its lyric lines and beats, and make each shot exactly as long as its timeline span, from data the server computes.

    Non-goals:

    • writing shot prompts;
    • planning and rendering in a single run;
    • LTX templates;
    • exact per-shot audio in the deliverable;
    • picking shots by their visual content;
    • per-shot kind and singer (stage D);
    • optional for_each entry fields, or entry defaults of any kind. That is Q4, and stage C must not settle it.

    Design

    Corrections (v1's sweep, still true)

    1. for_each takes only variable:, so planning is a separate run.
    2. The 17n+5 constraint refuses lengths under 124 frames. Grid numbers therefore come into plan_cuts as arguments copied from the template's own variable_constraints, and the engine holds no H3 number.
    3. No trim task exists, so trim_video is new and writes shots metadata.
    4. plan_cuts returns a dict, which has shipped.
    5. Per-shot references need an engine change (stage D, Q4).

    New corrections in v3 (from #627's build sweep and this session's sweep)

    1. Entry fields can't be optional. dw/for_each.py _item (:231-252) refuses an item:<field> that the entry lacks. Decided (Don, 2026-10-06): every entry carries num_frames, lead_frames and cut_frames. plan_cuts emits all three, and the stored default list spells them out. No engine change.
    2. References can't do arithmetic (dw/references.py:19-28). The slice can't start at start_frame - lead_frames in the template alone, so slice_audio gains lead_frames (Q6, decided).
    3. The H3 constraint snaps ("snap": "up", music-video.json:84-93), so an off-grid entry is rounded with a notice instead of being refused. Decided: drop the snap in music-video.
    4. task.py is at 1192 lines. trim_video goes in a new module, dw/tasks/trim.py, which registers itself the way cuts.py does.
    5. Unread entry keys warn and are never refused (for_each.py:345-384). This answers the tester's C-F223 note.
      • plan_cuts's lyric and kind aren't read by music-video. A plan passed with only a prompt added validates, with an unread-field warning that names them.
      • The skill tells the agent to drop both keys once the prompt is written. lead_frames and cut_frames are read by the trim step, so they don't warn.
    6. The edit's length is the sum of the trimmed clips, so it equals Σ cut_frames. pair_audio (fit: "video") cuts the song to that length. plan_cuts already makes Σ cut_frames = round(duration_s × fps), rounded once. This answers the tester's C-F224 note.
    7. The bare-string refusal already names the real argument. plan_cuts says to run transcribe_audio with 'timestamps': "segment" and mentions return_timestamps only as Whisper's name (cuts.py:70-76). Nothing changes here.

    Surfaces, decided here once (stage C)

    • plan_cuts grid arguments: modulus, remainder, min_frames, max_frames and lead_s, all optional. With none of them given, B's behaviour is unchanged.
      • Lead: lead_frames = min(round(lead_s × fps), start_frame). The first shot's lead is therefore clamped to 0.
      • Render length: num_frames = max(min_frames, smallest modulus·n + remainder ≥ lead_frames + cut_frames). The slack past the cut is a tail handle that gets trimmed.
      • Over-long shots: a shot whose render length would pass max_frames is split, preferring a beat, and the split is warned about.
      • Result: gains render_frames, the sum of num_frames, so the cost can be quoted.
      • start_frame and cut_frames keep B's meaning: the timeline cut start and the timeline span.
    • slice_audio lead_frames: optional, default 0, frame form only.
      • The slice starts at start_frame - lead_frames and runs num_frames.
      • A negative start is refused. It is refused statically where the values are literal (dw/slice_preflight.py, task_domains.py slice_region) and otherwise at run time.
      • lead_frames given together with start_seconds is refused.
    • trim_video(video, start_frame, num_frames):
      • keeps frames [start_frame, start_frame + num_frames);
      • cuts the clip's audio, if any, to the same span at the audio's own rate;
      • writes shots metadata through dw/shots.py (trimmed_shots), and is added to the constructor list in tests/test_shots.py;
      • refuses a range outside the clip, and a zero or negative count.
    • music-video template:
      • Variables:
        • song: {from_previous_result: write_song}, the way singer_reference works. slice and balanced read it.
        • Top-level num_frames is removed.
      • Entries: {name, prompt, start_frame, num_frames, lead_frames, cut_frames}, all required. The stored four-shot default gives each one num_frames: 124, lead_frames: 0, cut_frames: 124 and renders as today.
      • Constraint: the num_frames constraint (17, 5, 124, 345) stays, without snap. It applies per entry through item:num_frames, as in dialogue-short, and an off-grid entry is refused at arguments.shots[i].num_frames. cost_drivers and voxel_variables follow dialogue-short.
      • Steps:
        1. slice: lead_frames: item:lead_frames, num_frames: item:num_frames.
        2. shot: num_frames: item:num_frames.
        3. A new for_each step, trim: trim_video on the member's shot, with start_frame: item:lead_frames and num_frames: item:cut_frames.
        4. edit gathers trim.
        5. pair_audio stays the single final step.
    • music-video-cuts: passes H3's grid (17, 5, 124, 345) and a lead_s variable (default 0.5 s) to plan_cuts. Its description names the new entry contract.

    Stages

    A — analyze_beats (#625): built and verified.

    B — plan_cuts and music-video-cuts (#626): built and verified.

    C — pad-then-trim shots (#627; server deploy, about $7, breaking-change)

    • Builds: everything under Surfaces above.
    • Tests:
      • trim_video: frame and sample counts, refusals, shots metadata.
      • slice_audio lead_frames: the offset, the negative-start refusal (static and at run time), and the refusal alongside start_seconds.
      • plan_cuts grid arithmetic: a cut under min_frames, the lead clamp, the split past max_frames, and render_frames.
      • Pins to update:
        • test_for_each.py:618-716: step order, the trim group, edit gathers trim, song, and the per-entry num_frames;
        • test_plugin_skills.py:345 (the six entry keys), :594-603 and :638-656;
        • test_variable_constraints.py:485 (the named music-video exception) and :589-600;
        • test_result.py:2320,2345-2350;
        • test_pair_audio_fit.py:188-199;
        • test_step_cache.py:774-781 (regenerate the shot@* hashes);
        • test_catalog_structure.py:425,764 (description budget and cost).
    • Docs:
      • music-video and music-video-cuts descriptions;
      • minimax-h3 SKILL.md and references/cuts.md (the six fields, dropping lyric/kind, and "plan, read, prompt, render");
      • mentions in minimax-music3, series-episodes and script-to-video;
      • TASKS.md: trim_video, slice_audio lead_frames, the plan_cuts grid, and the music-video passage at :2087-2090;
      • WORKFLOW_GUIDE.md:635,784,1632;
      • RECIPES_24GB.md:125;
      • ARCHITECTURE.md:75;
      • the minimax templates README;
      • code comments that name the top-level num_frames (dw/vram_estimate.py:30).
    • Acceptance intent:
      • Grid: with H3's grid and lead_s 0.5 at 24 fps, plan_cuts makes a 2.0 s line into cut_frames 48, lead_frames 12 (0 for the first shot) and num_frames 124. Every num_frames is 17n+5 and at least 124. A span that needs more than 345 frames is split and warned about. render_frames is Σ num_frames.
      • Contiguity: each shot's start_frame is the previous shot's start_frame plus its cut_frames. Σ cut_frames = round(duration × fps).
      • slice_audio: start_frame 48 with lead_frames 12 returns audio starting at frame 36. start_frame 0 with lead_frames 12 is refused by validate_workflow. lead_frames with start_seconds is refused.
      • trim_video:
        • keeps exactly the asked frames, and the audio at its own rate;
        • carries shots metadata;
        • works for the whole clip and for the last frame alone;
        • refuses a range past the end, and a zero or negative count.
      • music-video:
        • The stored default validates and renders as before.
        • num_frames= at the top level is refused as an unknown variable.
        • An entry missing lead_frames (or either of the other two) is refused, and the refusal names the field.
        • An entry num_frames of 130 is refused at arguments.shots[i].num_frames, not snapped.
        • song: "asset:…" replaces write_song.
        • music-video-cuts's shots, with a prompt added to each entry, validate as music-video's shots. The only notice is the unread-field warning naming lyric/kind.
      • Real cost: one H3 render on lem, with 48- and 72-frame spans.
        • The deliverable's shot spans (from get_gallery_metadata or assess_output) are exactly the cut_frames.
        • Its total is Σ cut_frames.
        • The tester quotes plan.estimate and gets Don's go-ahead first.

    D — kind and singer per shot: not approved, deferred (unchanged from v2).

    • What it would build: an engine change (Q4), plus a cast map and the kind/singer fields on music-video, plus the skill's B-roll section.
    • When it comes back: it goes back to Don after C's real music-video run.

    Order: C is the only stage left. It is #627, re-scoped to this plan. No other feature blocks it.

    Risks

    • Snap carve-out. An agent used to H3 snapping may hand-write a 130-frame entry and get a refusal. The refusal names the grid, and the skill states the rule. Snapping here would be worse, because the render would quietly drift from cut_frames.
    • Render cost. Padding raises each shot's frame count: a 2 s line renders 124 frames. render_frames makes the cost quotable before a run.
    • Pin churn. About 20 test pins change, and that is still the bulk of C's cost.
    • Beat and Whisper quality: unchanged from v2. Field tuning will follow.

    Questions

    • Q1–Q3: decided by Don (2026-10-05). The beat tracker uses numpy/scipy. Planning is a separate run. The top-level num_frames is removed (breaking-change).
    • Q4: open, with stage D deferred. Stage C does not touch it.
    • Q5 (proposed follow-up): none found.
    • Q6: how the slice gets its lead. Decided (Don, 2026-10-06): slice_audio gains an optional lead_frames argument. start_frame keeps meaning the cut start everywhere, and hand-written entries get no fourth field.
      • Not taken: a plan_cuts-emitted slice_frame field per entry.
    • Q7: lead_s default in music-video-cuts. Decided (Don, 2026-10-06): 0.5 s, which is 12 frames at 24 fps and enough to hide H3's stiff opening.
      • Not taken: 0, no lead unless asked.
  5. added
    owner:donParked for human decision
    status:plan-reviewA feature plan is posted and waiting for Don
    and removed
    owner:leadFeature lead's turn (harnest R11)
    on Oct 5, 2026
  6. 45 remaining items

  7. added
    owner:leadFeature lead's turn (harnest R11)
    and removed on Oct 7, 2026
  8. dkackman commented on Oct 7, 2026

    @dkackman
    OwnerAuthor

    Close-out: back from the final check. Feature lead: claude-opus-5-5 via anthropic. One case failed, C-F328's render-rule bullet: a docs gap in stage C's skill text, which is a build miss and not a gap in the plan. I filed fix-forward stage #665 for it; its acceptance is C-F328 itself. The design record stands. The parent comes back for its last close-out turn once #665 closes.

  9. added 2 commits that reference this issue on Oct 7, 2026
  10. dkackman commented on Oct 7, 2026

    @dkackman
    OwnerAuthor

    Close-out: fix-forward done. Feature lead: claude-opus-5-5 via anthropic.

    Closed: fix-forward stage #665, which added the render rule (C-F328) to minimax-h3 SKILL.md and references/cuts.md. It was verified. Every stage (#625, #626, #627, #665) is now closed.

    Design record: docs/proposals/complete/music-video-timing-complete.md now has a Fix-forward: #665 section and a row in the bounces table. Commit bcd84d66, merged to develop as 7f524c4c. These are docs only, so there is no deploy.

    verify: run every case whose source: names one of this feature's stages, and close the parent if they all pass.

  11. added and removed
    owner:leadFeature lead's turn (harnest R11)
    on Oct 7, 2026
  12. dkackman commented on Oct 7, 2026

    @dkackman
    OwnerAuthor

    Close-out verify of #600: PASS, closing. Tester: claude-opus-5-5 via anthropic, lem on develop @ 7f524c4.

    The last close-out record had one failure: C-F328's render-rule bullet. Every runtime case and every other docs case passed in that record and the two sessions before it (C-F205–C-F218, C-F220, C-F221, C-F323–C-F326; C-F327 was verified in #627). Since then, only #665 has merged (7f524c4c), and it touches docs only. So in this session I re-ran C-F328:

    • The render rule now appears in both sources:
      • dw:minimax-h3 SKILL.md, music-video bullet (loaded with Skill): "an entry's num_frames is max(124, next 17n+5 ≥ lead + cut), the smallest 17n + 5 at or above lead_frames + cut_frames, at least 124; past 345, split the span."
      • references/cuts.md (lines 43–48) states the same rule, with examples: 12 + 48 renders 124, and a 130-frame span renders 141. It also says music-video does not snap. The order "Plan, read, prompt, render", music-video-cuts/plan_cuts, lead_s default 0.5 s, and dropping lyric/kind are all still there.
    • These were not re-read last session, and both are consistent now:
      • get_guide("workflows", section="for_each"): names music-video as a one-shots-list shape. It does not mention a top-level num_frames or a shared length.
      • get_guide("recipes", section="MiniMax-H3") (the 24 GB recipes): the grid is 17n+5 with 345 as the maximum, and nothing contradicts the six-field contract.
    • I didn't re-check the rest of C-F328 (descriptions, the tasks guide, get_task("trim_video")). It passed in the previous record, and stage C fix-forward: state the music-video render rule in minimax-h3 SKILL.md and cuts.md (C-F328) #665 changed neither the server nor those texts.

    No case in the suites is marked pending: for #625/#626/#627/#665. I added no new regression case, because C-F328 already covers this.

  13. added
    status:verifiedTester confirmed the fix via a real MCP call
    and removed on Oct 7, 2026
  14. added a commit that references this issue on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend:sharedenhancementNew feature or requestfeatureWork bigger than a fix: designed with Don, built in stages (harnest R11)owner:testerTester's turn to actpriority:2Backlog rank: solid ROI, moderate scopestatus:plan-approvedDon approved the feature plan (Don only)status:verifiedTester confirmed the fix via a real MCP call

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions