Architecture

The pipeline: from one track to a finished cut

How mvdirector turns a song into a lip-synced music video: a local orchestrator, three outside systems, two JSON state files, and a stage-by-stage pipeline that can be stopped and resumed at any point.

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

mvdirector (CLI command mvd) is a command-line application and Python library. It takes a song, as a single track, DAW stems or a Suno export, plus lyrics and a style brief, and produces a lip-synced, narrative or visual music video, or a long-form continuous mix. SongFilm is built on top of it.

The shape of the system

The orchestrator runs locally and never renders an image or a frame of video itself. It sends jobs to ComfyUI over HTTP, calls a language model for text direction and vision judgments, and uses ffmpeg to slice audio and assemble the final cut. Everything it needs to resume work is written to the project folder.

System context
Your machine
  • mvd orchestratorPlanning, state, quality gates, assembly
  • ffmpeg / ffprobeAudio slicing, frame extraction, final mux
  • Project folderanalysis.json · manifest.json · assets/
  • Review UIReads and writes the same manifest
ComfyUI · local, LAN or cloud GPU

Runs your bound workflows with any image or video model. Reached over /prompt, /view and /upload.

LLM provider · optional

Ollama, OpenAI-compatible, Claude, OpenAI or Gemini: direction, vision checks and prompt rewrites.

The orchestrator reaches each outside service through a small interface (LLMClient, FaceAnalyzer, MouthTracker, ComfyClient with an injectable transport). That is also how the tests swap them for fakes.

The language model is optional. With llm.enabled: false, planning falls back to deterministic rules and the vision checks and prompt rewrites switch off. ComfyUI is the only required remote dependency, and it can be on the same machine, on another computer on your network, or on a cloud GPU.

Four decisions that shape everything

  1. 1

    State lives in two JSON files

    analysis.json holds what was measured from the audio. manifest.json holds the visual bible, reference sheets, set plates, shot list and every generation attempt. Commands read them, do one job and write them back atomically.

  2. 2

    Timing comes from code, creative choices from the model

    Cut points, shot lengths, shot types and frame counts are computed from the beat grid and the vocal stem. The model picks framing, sets, wardrobe and prompts; code enforces the rules it must not break.

  3. 3

    Preflight assets are locked before generation

    Character reference sheets (one per wardrobe state) and empty set plates are generated and locked first. mvd stills and mvd run refuse to start while a locked asset the selected shots need is missing.

  4. 4

    Every generated asset passes a quality gate

    Stills and clips are scored automatically. A still must pass before any GPU time is spent animating it. A person reviews only what the review mode selects.

Stage by stage

Pipeline: command → file it writes
  1. 01mvd analyzeMeasure the audio→ analysis.json
  2. 02mvd planShot list and visual bible→ manifest.json
  3. 03mvd reference · platesLock identity and places→ assets/reference · plates
  4. 04mvd stillsGated by QC→ assets/stills
  5. 05mvd videosOnly from passed stills→ assets/videos
  6. 06mvd reviewApprove, redo, add notes→ manifest.json
  7. 07mvd assembleFrame-exact final cut→ output/<title>.mp4

Each stage reads the state files, does one job and writes them back atomically. Any stage can be re-run.

StageCommandWritesNotes
Analyzemvd analyzeanalysis.jsonBeats, bars, vocal windows, lyric timing. No network access.
Planmvd planmanifest.jsonCalls the LLM under a run lock. Will not overwrite an existing manifest without --overwrite.
Reference and platesmvd reference …, mvd plates …assets/reference, assets/platesGenerate candidates, then lock one. Locking records it in the manifest.
Stillsmvd stillsassets/stillsSinger stills are edits of the locked sheet; b-roll comes from text-to-image.
Videosmvd videosassets/videosOnly for stills that passed QC or were approved by a person.
Reviewmvd reviewmanifest.jsonApprove, redo the video, or redo the still and video. Notes become direction for the next attempt.
Assemblemvd assembleoutput/<title>.mp4Trims clips to frame-exact length and lays the original mix over them.

Resumable by construction

  • Manifest writes go to a temporary file in the same folder and are renamed over the target, so a crash never leaves a half-written file.
  • State is saved after every attempt, so a run can be interrupted at any point and picked up again.
  • One writer at a time. Planning and generation hold .run.lock; if a local process died and left the lock behind, the stale PID is detected and the lock cleared.
  • Every attempt is kept on disk and recorded with its seed, prompt, parameters and QC report, so any result can be reproduced or audited.
  • Both state files are versioned and have exported JSON Schemas; tests fail if the schemas or the filled-in examples drift from the models.

Frequently asked questions

Can I pause or re-run a single stage without regenerating the whole music video?
Yes. Every stage reads analysis.json and manifest.json, performs one job, and writes state back atomically. You can re-run a single shot or stage and assemble again without losing approved assets.
Does SongFilm lock me into one video model?
No. Both mvdirector and SongFilm separate pipeline orchestration from ComfyUI workflow graphs, so swapping image or video models only requires binding a new workflow file.
What does the review UI edit?
The review UI reads and writes the exact same manifest.json used by the CLI and assembly stage, so approvals, rejections, and director notes stay in sync with every shot.