Audio analysis

Timing comes from code: beats, vocals and cuts

How mvdirector measures a song and cuts it into shots on bar lines, who is singing when, and why the language model never decides when a cut happens. Includes an interactive cut planner.

4 min read · checked against mvdirector 0.8.0b2 · updated 2026-11-26

A music video that feels cut to the song needs cuts that land on the beat, lip-sync shots only where someone is actually singing, and the right singer on screen. mvdirector gets all of that from signal processing. The language model is never asked when to cut.

What mvd analyze measures

Analysis needs no network. The signal-processing helpers are pure functions over numpy arrays, so they are tested without audio files.

  1. 1

    Load

    The mix and the vocal stem are loaded as mono at 22,050 Hz with librosa.

  2. 2

    Beats and bars

    Beats come from librosa.beat.beat_track, run on the drum stem if one is configured and on the mix otherwise. Bars are every beats_per_bar beats (default 4). Bar intensity is the mean mix RMS per bar, scaled so the loudest bar is 1.0.

  3. 3

    Vocal windows

    Spans where the vocal-stem RMS is above −30 dB relative to its peak. Gaps shorter than 0.6 s (breaths) are bridged and spans shorter than 0.3 s (stem bleed) are dropped.

  4. 4

    Lyric timing

    Word timestamps come from a supplied JSON file, else from faster-whisper if installed. Lyric tokens are matched to transcribed tokens with difflib.SequenceMatcher, so transcription mistakes never change the lyric text.

  5. 5

    Estimate the rest

    Runs of untimed lines share the gap between their timed neighbors in proportion to text length. Alignment diagnostics are reported before any GPU money is spent.

Who is singing, not just whether someone is

  • Multi-singer vocal stems are diarized into solo voice clusters (voice_1, voice_2) and simultaneous harmony or unison turns (both), stored in Analysis.vocal_turns.
  • When lyric tags name the singers ([Verse 1: Singer A], [Chorus: Both]) or diarization hears several voices, cuts land on vocal transitions rather than across active singing.
  • Shot.singers records who is actively singing. Simultaneous duet shots are widened to two-shots, silent listeners in solo shots are told to keep their mouths closed, and the quality checks require the right number of faces to be present and synced.
  • Foreign vocals are muted in each singer's audio slice, so singers never lip-sync each other's lines.

Track profiling and auto-tune

With auto_tune: true (the default), mvd prepare, mvd analyze and mvd plan build a TrackProfile stored in analysis.json: language or code-switching, vocal mode (solo, duet, group, instrumental), rap and fast-flow density, drops and vocal chops, extreme vocals, and non-4/4 meter cues. That profile adjusts the Whisper settings, the video.* pacing parameters and planning.max_lipsync_share. mvd tune previews the changes and mvd tune --apply writes them to project.yaml.

Cutting the song into shots

The segmenter turns the beat grid into a gap-free list of shots. The demo below is a port of the real rules: the allowed bar steps come from the clip-length limits, fixed pacing cuts every N bars, and dynamic pacing scales shot length with bar intensity and snaps early to a new section or an intensity surge.

Interactive cut planner · a 32-bar demo song
Intro
Verse 1
Chorus
Verse 2
Final chorus
Shots
20
Average shot
3.2 s
Allowed bar steps
4 · 2 · 1
Intensity pacing
Applied
calm (< 0.55) medium peak (≥ 0.80) cut

Ported from planning/segmenter.py: allowed bar steps from the clip-length limits, intensity tiers at 0.55 and 0.80, early snap to a section start or an intensity surge, and the 0.15 contrast requirement. It leaves out vocal windows, singer handoffs and phrase slicing.

  • Allowed steps are the subset of 8, 4, 2 or 1 bars whose duration fits within video.min_clip_seconds and video.max_clip_seconds (defaults 1.5 s and 8.0 s).
  • Dynamic pacing needs contrast: if the intensity range across the song is under 0.15, cutting stays uniform. Calm bars (below 0.55) hold for the longest step, medium bars (0.55 to 0.80) take half of it, and peak bars (0.80 and up) take a quarter.
  • A shot is lipsync when at least video.lipsync_min_vocal_fraction (default 0.25) of it overlaps a vocal window; otherwise it is performance or broll.
  • Each shot gets its audio slice, which is the shot plus video.handle_seconds on each side, and a frame count: the smallest 8n + 1 that covers the slice, which is the frame rule LTX video models expect.

What the model is not allowed to decide

  • A lipsync shot stays lipsync; only shots with no sung vocal can become b-roll.
  • A lip-sync shot is never framed wider than medium_close by default (planning.lipsync_widest_framing).
  • How much of the song is the singer singing to camera is capped by planning.max_lipsync_share (default 0.45, a hybrid mix). Sung shots over the cap become cutaways, the quietest non-chorus shots first. Chorus and hook shots and the last sung shot always stay, and the singer is never off screen for more than two shots in a row.
  • Shots the model leaves out, or a batch that fails direction, get rule-based direction, so the manifest is always complete.

Frequently asked questions

Does the LLM choose when video cuts happen?
No. Signal processing computes the beat grid, bar intensity, and vocal windows first. The language model directs visual framing and storytelling inside those locked time spans.
How does mvdirector avoid turning an entire music video into nonstop lip-sync?
By default, planning.max_lipsync_share caps sung on-camera shots at 45%, converting quieter non-chorus vocal shots into narrative cutaways while preserving chorus hooks.
What if the automatic beat grid is a beat off from the real downbeat?
You can adjust the bar timestamps directly in analysis.json and re-run planning, or test bar-to-frame cut lengths ahead of time in SongFilm's free BPM and Beat Analyzer tools.