Project at a glance

RoleDesign and engineering, solo, and producer of the first film
Scope59 operations behind one registry; 13 database tables; 135 tests. The first film: 31 shots in 8 scenes, 35 sound cues, five cuts and a 90-second render
StackTypeScript, Next.js, React, PostgreSQL, Docker, ffmpeg, Python, DaVinci Resolve scripting, Model Context Protocol
StatusWorks end to end and has produced one film so far, a 90-second trailer called "536". The pictures, voice and music are AI-generated; the platform keeps the records, the rules and the checks.

Why I built it

An AI-assisted short film is hundreds of generated pieces: stills, clips, lines of narration, music cues. Without a system of record it falls apart fast. Which take was picked, what prompt made it, whether the cut still matches the plan, how much has been spent. I built Film Studio so an AI agent can do the generating while the film stays coherent, the budget stays capped, and the next film does not have to rediscover what the last one learned.

What it does

Breaks a script into shots

A script becomes scenes and shots with stable codes. Each shot collects takes, first as stills and then as clips, and one take of each is picked. Every take records the prompt, the model and the references that made it.

The Shots tab for the first film: the opening scene, with the picked still for each shot, its length and the line of narration that plays over it.

Keeps the look consistent

The bible holds the look, the characters and the locations. Each entry has exact prompt wording and reference pictures, and that wording goes into every generation that uses the entry, word for word.

A location entry in the bible: its reference picture, a description for people, and the prompt wording pasted into generation prompts exactly as written.

Lays sound against picture

Narration, music and effects are cues anchored to a shot and an offset, so they move with the shot if the cut changes. The page draws the whole film to scale.

The Sound tab: the film drawn to scale, with shots, narration, music and effects on one timeline, above the first narration line.

Builds the cut and checks the render

One command builds a timeline in DaVinci Resolve from the plan, renders it, levels the sound and checks the result frame by frame.

The Assembly tab: the cut drawn to scale with a thumbnail per shot, and the narration, music and effects tracks beneath it.

How it is built

The rest of this page is for the engineer who wants the detail.

Architecture

The platform is a Next.js app over PostgreSQL, with every read and write going through one operations registry. A job runner does the slow work, one job at a time: drawing title cards, mixing sound, building the timeline, rendering and checking. Media lives as files in a production folder; the database holds records about those files, never their bytes.

Generation happens outside. An AI agent calls the platform's tools, sends prompts to image, video, voice and music services through its own connector, saves what comes back into the production folder, and tells the platform about it.

Architecture: an AI agent and the generation services sit outside the platform. The agent and the person both act through one operations registry, which writes records to PostgreSQL and registers files in the production folder. A job runner drives ffmpeg and DaVinci Resolve.

One shot, from script to a frame in the render:

  1. Importing the shot list creates the scene and the shot, with a code that never changes.
  2. Importing the bible stores the prompt wording and reference pictures the shot will use.
  3. The agent starts a take, which passes the spend gate, generates a still, saves the file and finishes the take. The platform hashes and probes the file and registers it.
  4. A take is picked. A clip take is then animated from the picked still, and the frame's 2.39:1 band is cut from it as a new take.
  5. Sound cues are anchored to the shot.
  6. A build draws the title cards, mixes the sound and hands the plan to Resolve.
  7. A render comes back from Resolve, is levelled, and is checked.

Infrastructure and runtime

Docker runs one thing, PostgreSQL, with its image pinned by digest, its port published to the local machine only, and a named volume. Everything else runs on the host: the app, ffmpeg, a Python bridge to Resolve, and a headless browser that draws title cards. There are three databases, for production, development and tests, and the app refuses a database that is not on the local machine.

The app's database login can read, add and change records. It cannot drop or alter a table, and it can delete only from two housekeeping tables. Nothing in the film is ever deleted; records are archived.

Files are never overwritten. A file belongs to exactly one take, mix files and title cards carry a hash of their content in their names, and renders are numbered. Tests run in a throwaway schema with a temporary data folder, and both are dropped afterwards.

One registry, three interfaces

An operation is defined once, with its input schema, the callers allowed to use it and the records it touches:

"take.cancel": op({
  summary: "Call off a running take before it produced anything.",
  input: s.byId, kind: "write", callers: everyone,
  entities: ["takes", "spend", "productions"],
  run: async ({ id }) => end(id, "cancelled", {}),
}),

From that one definition come the web interface's calls, the command line, the agent's tools and the reference page that documents them. There are 59 operations, 21 that read and 38 that write. An agent sees 56 of them: the three that set a spending limit or reveal a file on disk are for a person only.

Spending and safety rails

Starting a take is the gate. Inside one transaction, under a lock for that production, the platform adds what has been spent, what running takes are holding and the new estimate, and refuses the take if the total would pass the lower of the cap and the approved amount:

limitCents = Math.max(0, Math.min(capCents, approvedCents))
allowed = estimateCents === 0
  || spentCents + committedCents + estimateCents <= limitCents

Money is whole cents. A test starts two takes at the same moment and proves both cannot squeeze under the limit. One honest caveat: generation happens in the agent's connector, so this is a rule the agent follows by starting a take first, not a lock on the service itself.

Saves carry a revision number, and a stale one is refused with the current record instead of overwriting it. A retried request carries a key, so it cannot be applied twice.

Assembly and the checked render

The plan is a pure function of the records. A shot starts on the frame nearest its start time and runs to the next shot's first frame, so rounding can never open a gap.

The Python bridge builds the timeline in Resolve one item at a time, then reads every item's position back from the tracks and compares it with the plan, instead of trusting what the calls returned.

Sound is mixed outside Resolve with ffmpeg. Music ducks 9 dB under narration, following an envelope worked out from the plan, so the same plan always gives the same file. The mix is levelled to -14 LUFS with peaks under -1 dB by a single steady gain; a limiter is added only if the peaks would otherwise pass the ceiling.

The check decodes every frame of the render, looks for black where no title card is planned, confirms the length is within a frame of the plan, and saves a contact sheet with one frame per shot.

Decisions that mattered

  • Standard loudness normalisation rode the level up and down and undid the balance set on the cues. One steady gain and a limiter on the peaks replaced it.
  • Scripted mixing inside Resolve was unreliable. The mix is made outside it, from the plan, and brought in as one file.
  • Resolve's scripting interface does not always do what it says. The bridge reads back what was really built, file names carry a hash because a changed file at the same path is not refreshed, and the render bitrate is set explicitly after "automatic" produced a 5.7 GB file.
  • Titles built by script rendered black. Title cards are drawn by a headless browser as images instead.

Testing

There are 135 tests in 7 files: 48 unit tests and 87 integration tests. The integration tests exercise every operation against a real database, hold concurrent writers at exact points to prove the locks, make real media with ffmpeg, restore a backup and compare it, and use a stand-in for Resolve that can misplace items or ignore a stop signal on purpose.

Limits and what is next

The app cannot generate by itself; an agent does that, which is why the spend limit is a rule and not a lock. There is no compositing, and media cannot yet be reused across productions. One film has been made. A person still has to watch it: the checks prove the render is complete, not that it is good.

What the project demonstrates

Film Studio shows how I build around tools I do not control: keep one source of truth, make every operation safe to repeat, verify what an outside system says it did, and put the spending rule where it cannot be skipped by accident.