Skip to content

About

One engine for video, images, audio and voice, with Postgres as its memory

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

438 Commits

Folders and files

Repository files navigation

media-engine

Constructive

CI status MIT license

Constructive Media: one engine for video, images, audio and voice, with Postgres as its memory.

npx skills add constructive-io/media-engine

Constructive Media treats everything it ingests or generates as data. Footage, stills, recordings and renders are rows; so are the people in them, the shots and words found inside them, the cuts made from them and every judgement a person or a model passed along the way. Models come and go behind adapters. The record of what was made, from what, and why stays in one database.

Features

  • 🗄️ Postgres as its memory — four pgpm modules, media-core, media-video, media-audio and media-image, hold every file, person, face, shot, word, cut and ruling as rows
  • 📥 Ingest and lineage — media ingest registers a file or a folder, media lineage shows what a file was made from, and media outputs lists every file the engine has made
  • 🎞️ Shots, frames and detection — media shots, media frames, media signatures and media detect split each video into shots, sample them, give each a colour and motion signature, and find the objects and people in it
  • 👂 Heard once — a recording is heard once and kept by its content (its size and a hash of its first and last megabyte) and by how it was heard (the model, the language, the names listened for), so a copy, a move or a rename is found again and media transcribe, transcript, captions, shorts, fillers and the rest say "heard before" in a line instead of hearing it again (--again hears anew); each leaves a 16 kHz sound copy, exactly what Whisper hears, so nothing after needs the original; media heard footage/ says what has been heard and what not
  • 🔭 Scouting — media scout footage/ --out scouted/ goes through every video in a folder tree one at a time: heard (or heard before), its script written, candidate clips picked by the local editor (or by counting), each written as a .conv ready for media shorts render with three stills, and index.html ranking every clip from every recording with its warnings (money, off the record, not for posting); resumable, with a STOP file, a disk floor, a lock shared with other jobs, and files kept only in the cloud brought down one at a time and given back
  • 📝 Transcripts put right — media transcribe writes down what is said, word by word with timings; media vocabulary, media mend and media relisten put right what was misheard, and media mend --undo puts it back; for files, a glossary of names (media transcript --glossary names.txt, heard => written a line) is listened for and mended in the script and its words, and media hear-again hears a stretch a second time (a bigger model, or a cleaner copy of the sound) and lists the words the two hearings disagree on
  • 🗣️ Speakers and personas — media diarize finds the voices in a recording and offers each the persona it sounds like, from the voice library or another recording, with how alike (sounds like ada (0.71)?); media name confirms whose it is, and a persona is the same row whether a model speaks in their voice or recognises it
  • 🧾 A recording written down — media transcript talk.mp4 talk.conv writes any recording as a .conv, a line a turn (a long turn broken at about 20 s), each placed in the recording with start: and end:, each word given to whoever said it, no library or database needed
  • 📱 Reframed to tall — media reframe talk.mp4 tall.mp4 cuts a wide video down to 9:16 (or 1:1, 4:5), the window following whoever is talking (by a transcript's words, or by whose mouth moves) the way a camera operator would: still, then easing after them, cutting with the shots
  • 🧹 Fillers cut out — media fillers talk.mp4 out/ takes ums, stutters and restarts out of a recording, with joins taken from the sound and a letter-by-letter check that puts back a cut it hears taking a word (listen to the joins the report lists); edit script.txt and run it again with --script; no flash shots: a kept stretch shorter than --shortest-shot (1 s) keeps a short filler rather than make a jittery cut, and punch-ins hold their framing 3 s
  • 💬 Captions — media captions talk.mp4 out.mp4 draws the words said on the video as they are said: a few big words at a time with the one being said highlighted (pop, for short vertical videos) or a line or two of subtitles (lines); font, size, colours, outline and place are settings, and the words are kept to caption again (--save-words, --words)
  • 🎬 Takes and sync — media group, media match and media sync put the cameras and recorders that rolled together on one timeline; media sync --check checks the offsets and media microphones tells who spoke each line
  • 📏 Sound and picture measured — media loudness, media audible, media laughter and media coordination measure how loud a shot is against what surrounds it, how well a line can be heard, where people laugh and how what is lit moves
  • 🏅 Scores, recipes and rankings — media passages, media flag and media score turn what was measured into scores from 0 to 1; media recipe says which count and media rank lists the best
  • ⭐ Highlights — media highlights talk.mp4 finds the moments of a recording that would hold up cut out on their own, a hook, a claim, a story, a laugh, each with its times, a title, the hook, why and a score, read by a local text model with who said what, the laughs and the questions answered marked; --brief says what to look for
  • 🔎 Judged and found by meaning — media judge has a text model read the best passages, media index and media search find passages by what they mean, and media search --cut NAME stores the answer as a cut
  • ✅ Decisions that are kept — media keep and media cut rule a passage or a shot in or out of every ranking and cut; media prefer and media fit teach a ranker from your choices, and media script --read takes a marked-up script back
  • ✂️ Shorts as scripts — each short comes with its .conv; edit a line's trim, a push-in (zoom:1->1.3), a pan, a punch-in at a word (<key zoom:1.6 ease:hold>), who it follows, each shot's framing (split at the recording's cuts, in plain numbers; media shorts frame writes it for lines you picked by hand, a take's too), a slide placed high or cut down to its words (fit:top, fit:content, both at once: fit:content-top) with the captions in the band it leaves, a dissolve or a J-cut, a slide held until its fade-in settles ([cut settle]), one line's captions in a style of its own (caption:chip, caption:off), and media shorts render short.conv short.mp4 makes it again
  • 🔊 Sound made again — [sound cleaned/mix.wav under:-14] hears a short through cleaned voices or a stem laid on the recording's timeline, the recording's own sound 14 dB under it; at:1:02.5 for a file that starts later, and in a take on the take's timeline with each line's microphone under it; [sound best] is its own again
  • 🧵 Several recordings, one short — [source FILE] again mid-script (or source:FILE on one line) cuts one short across an opening, a talk and an interview: one pass, captions across it all, each recording's sound evened with the others before the whole is made loud
  • 🧑 Following one person by their face — face: right, face: 4:22 middle, face: 52 or face: faces/jo.jpg on a character, and follow:JO frames them by likeness and nobody else (in a take, with no face:, the face their voice comes from): found at the recording's own size on 4K, followed as a handheld camera moves, the whole picture while they are out of view; and no framing leaves a face half in the frame
  • 🔤 Captions as written — {CVSS|C V S S} in a short's script captions "CVSS" while "C V S S" is said; 1.5{M|} shows a word the speaker swallowed, and the render lists it
  • 🎨 Colour — [grade log] turns flat log footage into a picture for a phone with the engine's own curve; [grade lut:show.cube] a LUT of your own; contrast:, saturation:, brightness:, warmth: by hand; per camera of a take (camera:WIDE) or per line (grade:off), and in a show's .look
  • 🏷️ A show's look, in a file — captions as a card or a chip, timed by when each word was said, name cards ([name Jo Example | Host]) and a logo ([overlay logo.png at:top-right]) kept in one .look file; each short says [look show.look], and media shorts render out/ --preview makes every short in a folder, with a small copy for a phone
  • 🎥 Shorts from a whole shoot — [source take:panel-01] cuts a short from a take, several cameras and microphones lined up by media sync: each line seen through the camera it names ([camera WIDE], camera:TIGHT) and heard through its speaker's own microphone (mic: on the character, or who media wear says wore it, or the one that heard it loudest), or the microphones mixed ([sound mix]); captions timed by the words heard there. media shorts take:panel-01 out/ picks the shorts too: what was said once, from the microphone that heard it loudest, and each line's camera graded on the faces it frames, tight on someone talking at length (cut to the wide at a sentence's end after --widen seconds) and wide for back and forth, held at least --shortest-shot
  • 🧠 An editor on your machine — with a text model set (one you run yourself, by default), media shorts has it choose each short's whole sentences: opening on a hook (its strongest sentence moved to the front, then cut back to how the thought began, as an editor does), stitching two or three spans with [cut], leaving out anything said off the record, its reasons kept in the .conv, its titles held to what is said, and [grade log] written for a camera shot flat; with none, or when it fails, the picks are counted. media shorts sentences take:NAME --json prints the numbered sentences for any other editor, an agent or a person, and --spans 12-15,3-4 makes their choice
  • 🏭 Many cuts, unattended — media shorts run plan.toml makes cuts all night from a plan you write: recordings, takes, a folder of scripts and reels, the variations to draw from (shape, length, look, captions, the wide cut, the opening, the grade, the editor on or off), a seed and a budget (hours, cuts, gigabytes, a free-disk floor). The local editor's questions take a shared lock one cut at a time, the cuts are made side by side (on the video hardware, when asked), each as a small copy and its script, never from a file kept only in the cloud; a pick that repeats an earlier one is skipped, a failed cut is told of and the run goes on, a rerun goes on where it stopped, a STOP file stops it, and its index.html ranks the cuts, three stills each, with the editor's reasons and rating and the engine's warnings
  • 🔎 Cuts checked by machine — media shorts check short.conv (or a run's folder) looks a finished cut over for the faults that need no taste, each a finding with a time and a reason: a cut point inside a word, a face at the frame's edge or gone from it, captions that are not what is heard, no sound, loudness off, dark frames; a check whose model is not set says so and the rest still run. media shorts run checks each cut as it makes it and ranks by it, and media shorts report out/ gives a run's numbers: made, not made and why, findings by kind, the spread of scores, and once a review has answers, how often each check's flagged cuts were kept
  • 📱 Shorts — media shorts talk.mp4 out/ cuts short films from a long recording: the stretches of whole sentences that stand on their own and hold a viewer, never anything said off the record (and media shorts render warns of that, of money talk and money shown on a slide, and of a zoom carried into a new shot), framed 9:16 on the faces in them (an edited talk shot by shot: a slide shown whole, a small face zoomed in to, a close-up held), or at their own size, captioned and made loud enough, in seconds
  • 🎞️ Reels — media reel scout footage/ picks/ grades every clip of an event half a second at a time against the rest of that event (sharp and exposed, its light and colour, a light in the frame or its colour changing, a steady camera with no jolts, faces toward the lens, life moving in a still frame), leaves out the blurred, too-dark, shaking, whip-panned, pocket, covered-lens and talk shots with why, and ranks moments of 1.5 to 5 s with variety weighed in on a contact sheet; media reel make footage/ reel.mp4 --music bed.mp3 --length 30 opens two bars before the music's drop, lands the best shot on it and cuts on the beats (found to the millisecond in the sound), framed 9:16 on the faces in them or shown whole over a blur when a crop would cut someone off, 120 fps phone clips at half speed and HDR clips brought down to ordinary video, and writes the cut as a .reel script, a shot a line, that media reel render makes again after an edit
  • ✂️ Cuts and timelines — media compile picks shots that are good and unalike, media assemble cuts an interview from its best passages, media cutaways lays footage over it, and --after revises a cut by what media note said of each clip
  • 📤 Render and export — media render makes a cut into a file to watch; media export writes FCPXML and a CMX3600 edit decision list that point at the original recordings
  • 📜 Scripts said and checked — media conv reports everything wrong in a .conv script; media say says every line in its persona's voice, listens back and says it again until a take passes
  • 🔤 Said as meant — layers lay how a line is said over what it says: numbers, web addresses and acronyms by default ("$3.50" is "three dollars fifty", "API" is "A P I"), fillers, tech words and a project word list when asked; media say --dry-run shows every line said differently, and --layers none says each as written
  • 🧪 Evals — a slot's evals give it a bar to pass and a set number of tries, so nothing is tried forever (speech, transcription and reading so far); media eval speech, transcription or reading scores an adapter on lines whose words are known and writes it down with the model's name, and a plugin adds evals of its own
  • 🎚️ The mix — clips on named tracks, brought to a level, looped, faded, ducked under speech and put through effects; media say --stems writes each track on its own beside the mix
  • 🎭 The stage — media film films the page that follows a render, as a deck, a document or a walkthrough; media still takes pictures of chosen moments, media stage serves it to your own browser and media print writes a page as a PDF
  • ✍️ Prose — media library prose keeps how a persona writes, as passages of their own with their consent, and media write has any text model write a script in their manner, or a conversation between several
  • 📄 Reading documents — media read scan.pdf scan.md takes a PDF's own text where it has some and has every other page read by a main reader, a second and a witness, keeps every reading so a rerun reads only what is new, and checks them the way media say listens back: word by word, words counted, loops, totals added up, lines read unsurely, with a report and a crop of the page for each thing to look at; --settle serves a page to settle each disagreement, kept with who settled it, and media eval reading scores a reader on pages whose words are known. The built-in reader (PP-OCRv6 through ONNX Runtime, no OpenCV) says where each line is; --reader http:MODEL asks any vision or OCR model you serve yourself, such as olmOCR 2
  • 📷 Photographs — media photos add dates a folder of old photographs from the camera, the file name or the folder and finds and groups the faces in them; media photos serve is a page to name whole groups at once and confirm suggested faces a key at a time; media photos sort moves each photograph gone through into a sorted folder as 2005-04-09-Ada-Ben-9f2c41ab07.jpg (date, first names, a lasting id), sets duplicates aside and renames it when its people change; media photos alike finds the same picture kept twice though the files differ (rescans, smaller copies, re-saves) and keeps the best copy with every name carried over; media photos export keeps every name and date by file hash; media photos undo puts any batch back
  • 🗒️ Media notes — a NAME.media-notes.json beside any photograph, recording or video says what it is (by its content, so a moved or renamed file keeps it), what it was made from, and what people and models said of it: who is in it and speaking, what is seen, where to look and where not, where to cut, how a cut was rated and what was wrong with it, each placed in time and in the picture with who said it and how sure. media notes FILE says what is true now (a person over a model, a newer word over an older), media notes add writes a note safely and carries a note on a cut back to its footage, in the footage's own time; find, trace, merge, check and index do the rest. A JSON Schema, a TypeScript reader and shared conformance files come with it
  • 🌳 Lives — media life reads one person's life out of a family tree file (GEDCOM) as a sheet in order, with how many records are behind each line and what the file does not say, for media write to tell as a story
  • 🎙️ Voices — media clean and media reference make a clip a voice can be cloned from, media voice gives it to a persona, media audition has it say lines it has never seen, and media blend and media mimic make a voice from others
  • 📚 Libraries — voices, sound banks and faces in repositories of their own, each voice with its consent; media library add, search and check use them, and media library lock and install keep a project's at a commit
  • 🧱 Boilerplates — media init workspace NAME starts a project and media init deck NAME adds a deck to it, from a repository of templates that pgpm init --repo reads too
  • 🖼️ Pictures and video — media generate image, media generate video, media generate audio and media generate music hand a description to a model on your own machine and put what it makes on record as generated; a script's prompt: sounds are made the same way; media generations lists every request and media synthetic lists the clips of a cut that nobody filmed
  • 💬 Talking with a model — media talk serves a page on your own machine that hears you, answers a sentence at a time and stops when it is spoken over; --measure times each of the three models
  • 🎤 Recording a voice — media record LIBRARY serves a page that gives words to read in each mood, shows the microphone live, checks every take for length, level and room noise, and cuts the take you keep into the library's clip, with the consent you give
  • 🔌 Plugins for the rest — media revoice says a recording again in another voice, media adr replaces a video's dialogue with a clean stem a person, media separate takes a voice out from over music and media lipsync makes a face say a recording, each through a plugin
  • ⚖️ One license rule — the code is MIT and imports only MIT, Apache-2.0 and BSD packages; tests/test_licenses.py fails the build otherwise, and no model weights, voices or footage are in the repository
  • 🤖 Agent skills — npx skills add constructive-io/media-engine gives a coding agent the skill in .agents/skills/constructive-media: setting up, a script to sound, footage to a cut

Local first

Everything the engine does runs on your own machine, with no network. Where a model helps (hearing words, choosing what a short opens on, saying a line in a voice), the one used by default is one you run yourself, and a hosted model is used only when you set it, for the run or for good. With no model set, a command still works: media shorts counts what it cannot read, and says so in a line. A model can always be asked to step in, by choice: set the text slot to a hosted endpoint, or have an agent read media shorts sentences and write the short's .conv itself, which media shorts render makes. media shorts run makes many cuts with no one in the loop, by the same local editor.

What a model has heard is kept: a recording is heard once, by its content, and no command hears it again unless asked (docs/HEARINGS.md).

Pluggable by design

Nothing in the engine is tied to one model. The database driver, every model, the effects and the browser each sit behind a slot, and an adapter fills it. media adapters lists every slot and what can fill it on your machine, with the license of each. CONSTRUCTIVE_MEDIA_ADAPTER_<SLOT> chooses one, so swapping a model is a setting, not a code change.

A plugin is a separate Python package that fills a slot from outside this repository. Install it next to constructive-media and the engine finds it. A plugin is never the default, and it cannot replace a built-in adapter. Six are in media-engine-plugins, each a package of its own:

Plugin Fills the slot Chosen as What it adds
pedalboard-effects effects pedalboard The reverb, delay, compression and gain a script asks for, through pedalboard
ultralytics-detection detection ultralytics Ultralytics YOLO detectors for media detect
seedvc-conversion voice_conversion seedvc media revoice, media adr, and media talk --voice WHO --quick NAME
ltx-video video ltx A still made to move: media generate video "…" --from PICTURE --adapter ltx
demucs-separation separation demucs media separate: a voice taken out from over music
latentsync-lipsync lip_sync latentsync media lipsync: the face in a video made to say a recording
blender-render render blender media draw --renderer blender: final frames of a glTF, USD or Vim3D scene, with Cycles or EEVEE

The voice_conversion, separation and lip_sync slots have nothing built in, so the commands that use them run only when a plugin fills the slot. Each plugin's README says what its code and its model are under. Read it before you install one.

Make your own

  • 🔌 A plugin — an ordinary Python package with an entry point in the constructive_media.adapters group; it names its slot and its license, and the slot sets what it must do
  • 📚 A library — media init library NAME starts a repository of voices, sound banks and faces with a media-library.json; media library check says everything wrong with it
  • 🧱 Boilerplates — a repository of folders with blanks in them; media init --repo owner/name reads yours in place of the default
  • 🎭 A page for the stage — any HTML that loads the player is filmed with media film --page FOLDER; a page served by something else is filmed with --url when it keeps the contract

Status

Early, and built in the open one layer at a time.

Layer State
Schema modules (packages/) Here, tested, audited
Settings and the adapter interface for the database, models and effects (python/) Here, tested
Engine and media command line: ingest, lineage, shots, frames, signatures, detection, transcription, takes and sync, speakers, the sound measured (how loud a shot is against what surrounds it, how well a line can be heard, where people laugh) and the movement of what is lit against the rest of the picture, passages, flags, scores and rankings, decisions, shot selection and timelines, a ranker taught from preferences, interviews assembled from passages with footage laid over them, cuts rendered to a file and exported to an editing program, a text model's opinion of the best passages, search by meaning Here, tested
.conv scripts read and checked, held to the format's own conformance files Here, tested
The mix: clips on named tracks, brought to a level, looped, faded, ducked under speech and put through effects, written with a stem for each track Here, tested
The check on a spoken line: what was heard against what was meant, a voice's reference recording leaking into the line, a stutter, a line cut off, a click at the start Here, tested
Speech: voices kept by persona and emotion, a client for any server that speaks, and a line said again with another seed until a take of it passes the check Here, tested with stand-ins for the models
.conv scripts rendered to sound: every line said and checked, every sound put in its place, the whole mixed to one loudness, with the lines, the stems and a manifest kept beside it Here, tested with stand-ins for the models
The stage: a rendered script filmed as a video. A page follows the recording, as a deck, a document or a walkthrough, with the speakers, captions and clips drawn over it; a browser with no window is watched, and the pictures are laid under the sound Here, tested, and filmed with a real browser
Voices: a noisy recording measured and cleaned, a recording cut into a clip a voice can be cloned from, the clip sent to a server that clones or to a model run on a Mac with no server, a voice auditioned before it is used, a voice blended from others and kept as one of its own, a small quick model's own voices mixed until they lean towards a recording, and, with a plugin, a recording said again in another voice Here, tested with stand-ins for the models
Libraries: voices, sound banks and faces in repositories of their own, each voice with its consent, added by address and kept at a commit Here, tested
Prose: how a persona writes, kept as passages of their own, and scripts written in their manner by whatever text model is configured, with nothing trained Here, tested with a stand-in for the model
Media notes: a notes file beside any media file, its current view worked out from a log of what people and models said, notes on a cut carried back to its footage, the engine's recognition said as notes, a JSON Schema, a TypeScript reader and conformance files both readers pass Here, tested
Lives: a person's life read out of a family tree file, in order, with what each line is known from, what is not known, and who may be living Here, tested
Starting a project: media init makes a workspace and its decks from a repository of boilerplates, in the format pgpm init reads Here, tested
Pictures, video and sounds made from a description by a model on your own machine, every request and what it made kept on record apart from what was filmed Here, tested with stand-ins for the models
Photographs: a collection dated from the camera, the file name or its folders, its faces found, grouped and named on a page, and copied or renamed into order with every move able to be put back Here, tested with stand-ins for the model
Talking with a model: a page on your own machine that hears you, answers with a text model and says the answer back a sentence at a time, and stops when it is spoken over Here, tested with stand-ins for the models
Plugins for what the core leaves a slot open for: a recording said again in another voice, a voice taken out from over music, the face in a video made to say a recording Here, tested with stand-ins for the models
Engine: sounds made from a description Being brought in

The roadmap is in docs/ROADMAP.md.

What is in the box

Module Schema Holds
media-core media Personas, voices, assets, takes, episodes and what was derived from what
media-video media_video Shots, frames, transcripts, passages, timelines, scores and editing decisions
media-audio media_audio Emotions, text models, renders and human review
media-image media_image Photographs: when each was taken and how that is known, the faces in each and whose they are, and every file moved; what each reader read on each page of a document

media-core is the spine: a persona is the same row whether a model is speaking in their voice or recognising it in a recording. The other modules depend on it and never on each other.

The Python engine in python/constructive_media needs only a database driver; each part of it adds what it uses as an optional extra. It reaches the database, every model and every effect through an adapter, so a model is swapped with a setting and a tool under another license plugs in from outside this repository. Video and audio are read and written by the ffmpeg program.

The engine ships no models, voices, footage or people. You bring your own.

Installation

git clone https://github.com/constructive-io/media-engine
cd media-engine
pnpm install

You also need PostgreSQL 17+ with pgvector and pgpm (npm install -g pgpm). See Prerequisites.

Usage

Deploy the schema into a database of your own:

# Docker, or skip these two lines and export PGHOST/PGPORT/PGUSER/PGPASSWORD
pgpm docker start
eval "$(pgpm env)"

# media-video, media-audio and media-image bring media-core with them
pgpm deploy --database media --createdb --yes --package media-video
pgpm deploy --database media --yes --package media-audio
pgpm deploy --database media --yes --package media-image

Install the engine with Python 3.11 or later. You also need ffmpeg on your path, and whisper.cpp for transcription (brew install whisper.cpp):

pip install ".[video,detection,speakers,audio]"   # or just `pip install .` for the core
export CONSTRUCTIVE_MEDIA_DATABASE_URL=postgres://postgres:password@localhost:5432/media

Then point it at some media:

media ingest ~/footage --project demo  # register every file, once
media shots                          # split each video into shots
media frames                         # save and measure sample frames
media signatures                     # a colour and motion signature per shot
media detect                         # find objects and people in the frames
media read page.png --lines          # the words on a page or a frame, each line with where it is
media read scan.pdf scan.md          # a whole document, read by several readers and checked: scan.checks/report.md
media vocabulary Zentrova "Ottoline Varga" --project demo  # names to listen for
media transcribe                     # what is said, sentence by sentence, word by word
media vocabulary Zentrova --heard-as "zen trova" --project demo  # what a name is misheard as
media mend                           # put right every mishearing on record, and keep what was heard
media relisten                       # transcribe the weakest recordings again, and keep what is better
media heard footage/                 # each recording heard (once, kept by its content) or not; no paths: every hearing kept
media scout footage/ --out scouted/  # every video heard once, candidate clips picked and ranked in scouted/index.html
media group                          # recordings that rolled together become a take
media match                          # a recorder with no clock finds its camera by what was said
media sync                           # place every recording on its take's timeline, and prove it
media takes                          # each take and how much of it is placed
media overlap interview desk         # the sentences two recordings share, and the offset each one implies
media pull interview --at 1:20       # the same moment cut from every recording, to hear whether they are in step
media take interview --offset desk -31.25  # say an offset outright; sync builds on it and never moves it
media diarize                        # tell the voices in each recording apart
media speakers                       # each recording's voices, and a clip of each to listen to
media name interview voice1 "Ottoline Varga" --new  # say whose voice it is
media transcript talk.mp4 talk.conv  # any recording as a .conv: a line a turn (a long turn broken at about 20 s), each placed in the recording
media hear-again talk.mp4 --model large-v3 --from 240 --to 300  # heard a second time: the words the two hearings disagree on, with when
media wear interview collar "Ottoline Varga"  # say who wore a microphone
media microphones interview          # give each line to whoever's microphone heard it loudest
media loudness                       # how loud each shot is against the minute around it
media coordination                   # whether the lit part of each shot moves with the rest of it
media audible                        # how well each line can be heard: the noise under it, and distortion
media laughter                       # where people laugh, as candidates to say yes or no to
media passages                       # cut each take's speech into passages worth using
media score                          # flag what to cut, then score every passage and shot
media rank interview --top 10        # the best of them, and how much each was measured
media judge                          # a text model reads the best of them and says whether anything is said
media index                          # make every passage findable by what it means
media search "the winter the boats came in close"      # the passages that answer to it
media search "why the light went out" --cut dark --seconds 60  # or a cut of them
media script --out script.md         # the best passages as a document to mark keep, cut or trim
media script --read script.md        # store the marks as decisions
media compile reel --count 12        # shots that are good and unalike, stored as a cut
media note reel 3 drop               # say what you made of a clip
media compile reel-2 --after reel    # the next cut: what was kept stays, what was dropped is replaced
media pairs --render pairs/          # the shots a ranking cannot tell apart, side by side to choose between
media prefer 3f9a01c2 77b0de41       # which of two you would use
media fit --save taste               # a model of what you prefer, tested on footage held out from it
media models                         # the fitted models, and how each did on footage held out from it
media decisions                      # everything ruled so far, newest first
media recipe reel --like broll --weigh preferred=0.5  # a recipe that ranks by it
media assemble talk --take interview  # the best passages as a cut, each seen and heard through the right recording
media assemble film --take interview --story --switch  # a text model chooses and orders them into a story; camera changes clip to clip
media cutaways talk-over --over talk  # other footage over some of it, the sound untouched
media flags talk-over                # every flag inside the cut, and what cutting them would save
media render talk-over               # the cut as a file to watch
media relink talk-over talk-table table  # the same cut heard through another recording of its take
media render talk-over --mix         # or through its worn microphones, mixed to follow whoever is speaking
media export talk-over --to handover/ --preview --renders  # the cut for an editing program, with something to watch beside it
media lineage out.mp4                # what a derived file was made from
media outputs                        # every derived file on record, and what is lying about that is not
media generate image "a harbour at dawn, fog over the water"  # a picture from a description, on record as generated
media generate video "fog lifting off the harbour" --seconds 2  # or a piece of video
media generations                    # every request, how it came out and where the file is
media synthetic talk-over            # the clips of a cut that nobody filmed
media train ada photos/ada --word adamrsh --by "Ada Marsh"  # teach the picture model a face from photographs
media generate image "adamrsh at a harbour at dawn" --like ada  # and make a picture of her
media persona "Ada Field" --new --kind character --bio "Keeps the light."  # who somebody is
media personas                       # everybody, and the voices each has
media write ada "the fog last night" --out scene.conv  # a script in her manner, from passages of her own
media life tree.ged "Ada Marsh" --out ada.md   # her life as a family tree file has it, to write a story from
media proof story.conv --page .                # read a story for lines that are its making, not the story; a score of 100
media conv scene.conv                # check a .conv script: every problem, its line and how to mend it
media voice "Ada Field" ada-plain --new # give a persona a voice, by the name the speech server knows it by
media say scene.conv out/scene.flac --stems  # the script as sound, each line said until a take of it passes
media purge out                      # what finished renders kept to be worked on, and with --yes take it away
media status                         # where things are kept and what is held
media adapters                       # every slot and what can fill it

Every stage picks up where it left off and only works on what is new. A model is downloaded the first time a stage needs it: 1.6 GB for the default transcriber, 29 MB for the default speaker model.

A transcript is kept right without listening to everything again. A term in the vocabulary can carry what the recogniser writes in its place, and media mend rewrites exactly those, in the lines and in their words, keeping a plural or a possessive. What the recogniser wrote stays beside each line and word and every change is recorded, so media mend --dry-run shows what would change and media mend --undo puts all of it back. media relisten finds the recordings the recogniser was least sure of, or wrote little for, and listens to them again with another adapter or a larger model; the new transcript replaces the old only where it is surer and found no less. media transcribe --from FILE listens to another file in place of one recording, the same sound cleaned up, and --speaker NAME writes a name beside every line of a microphone only one person wore.

A take is the camera and the microphones that recorded one moment. media sync works out how far apart they started from the words they share, then from how the sound rises and falls, then from the devices' clocks once those are shown to agree. Every answer is checked against what is actually said at the same moment in both, and one that fails the check is not stored. media sync --check runs that check on what is stored and changes nothing.

Sometimes there is nothing to go on: a recorder whose clock was never set, a camera that heard only music. A person who was in the room still knows which files belong together, so media take makes a take by hand or mends one: which recordings are in it, what each is to it, which is the primary, and how far each is from the primary. An offset said there is stored as manual, and media sync builds on it and never moves it. Two commands give the evidence to say it on. media overlap shows the sentences a recording shares with the take's primary, the time each says them and the offset each sentence implies, beside the offset the take has stored; it reads transcripts and changes nothing. media pull cuts the same stretch of take time out of every recording: if the offsets are right, every file says the same words from the same instant, and each file is recorded with the offset it was cut under.

media diarize listens to what was transcribed and finds how many voices there are and which lines each one spoke. It does not know who anyone is. It calls them voice1, voice2 and so on and cuts a short clip of each; you listen and say who it is with media name, once, and every line that voice spoke carries the name. A voice already named in one recording, or one that sounds like a clip in the voice library, is offered with how alike it is (sounds like ada (0.71)?) and never applied without you. An hour and three quarters of talk is gone over in about fifteen seconds. media diarize --dry-run finds the voices and stores nothing, and media speakers --people adds each named person up over every recording: how many lines, how long, and in how many recordings.

Where everyone at a table wears a microphone there is a second way, and it needs no model. media wear says who wore which recording of a take, and media microphones gives each line to the wearer of the microphone that heard it loudest, each measured against its own loud level so that a recorder turned up high does not win everything. A line no microphone leads clearly is left without a name, and a line a person named is never changed. The two ways check each other: each microphone's lines are counted by the voices media diarize found, and one that carries more than one voice is said to.

media passages reads a take as one conversation, however many microphones heard it, and cuts it where the talking stops. media score flags the fillers, stutters, dead air and lines the recogniser guessed at, then scores each passage and shot from what was read, heard and seen. A score nobody measured is left out, never counted as a zero, and media rank says how much of its recipe each result was measured on. A passage in which someone asks for something not to be used is never ranked, whatever it scores, until a person dismisses that flag. media flag runs the flags on their own. A ranking is narrowed with --take, --match (a pattern the file's or the take's name fits), --min-words and --at-least SCORE=FLOOR, which keeps only what scored that much on one score and can be given more than once.

Four commands measure what the words and the pixels do not say, and media score turns each into scores. media loudness gives a shot its lift: how far it sits above the minute around it, which is where a cheer or a gasp shows (energy_lift). media coordination follows what is bright and strongly coloured in a shot, and everything else, and says how closely the two move together over the shot's best four seconds (coordination). media audible measures each transcribed line for itself: the noise under it, how far the speech stands above that, and how much of it was cut off at the top of the scale (audio_snr, undistorted, spectral_balance). A recogniser is as sure of a muffled line as of a clear one, so this is the only measure of whether anyone would want to listen, and media assemble takes each passage's sound from the cleanest recording measured. media laughter finds where people laugh, from the sound, since a recogniser throws laughter away. What it finds are candidates: media laughter --yes ID or --no ID says which are right, and a passage is credited with a laugh in it or in the six seconds after (laughter).

The recipes that come with the engine weigh energy_lift and coordination for shots. The others count once a recipe weighs them: media recipe talk --like interview --weigh audio_snr=0.5 --weigh laughter=0.5.

media judge asks what no measurement can: whether anything is said. A passage of thanks scores as well as an explanation on every measure of form, so the best-ranked passages, most said in the least time first, are read by a text model, and what it makes of each is stored as three more scores with the model's name on them: substance, interest and self_contained. They are scores like any other, counted by a recipe that weighs them (media recipe said --like interview --weigh substance=1), and a passage is read once by each model. media index keeps every passage as an embedding and media search finds the ones nearest a question in meaning, weighed with how good each is, so a passage that is on the subject and unusable does not come first. --answers has the text model check that each one answers the question and is not only about it, and --cut stores what was found as a cut. A passage whose words have been corrected drops out of search until it is indexed again.

Both models are reached over HTTP, on any server that speaks the chat-completions and embeddings API: llama.cpp, Ollama, vLLM, or a hosted one. Nothing is sent until you name the server and the model, so your transcripts go where you send them and nowhere else, and a passage in which someone asks for it not to be used is never sent at all:

export CONSTRUCTIVE_MEDIA_URL_TEXT=http://localhost:11434/v1
export CONSTRUCTIVE_MEDIA_MODEL_TEXT=the-name-the-server-knows-it-by
export CONSTRUCTIVE_MEDIA_URL_EMBEDDING=http://localhost:11434/v1
export CONSTRUCTIVE_MEDIA_MODEL_EMBEDDING=a-model-that-gives-1024-numbers

CONSTRUCTIVE_MEDIA_KEY_TEXT and CONSTRUCTIVE_MEDIA_KEY_EMBEDDING hold a key for a server that wants one. CONSTRUCTIVE_MEDIA_EXTRA_TEXT is a JSON object sent with every request, for whatever a server calls its own options. A model that thinks before it answers needs it, either to be told not to ({"reasoning_effort": "none"}, on a server that takes that) or to be allowed enough for both ({"max_tokens": 2000}); media judge says so when a model spends everything it was allowed and answers nothing.

The moments worth cutting out

media highlights works on one recording, with no footage library or database: give it a video and it says which stretches of it would hold up as clips on their own.

media highlights talk.mp4 --count 5 --save-words talk.words.json
media highlights talk.mp4 --words talk.words.json --brief "the strongest claims about testing" --out picks.json

It writes the recording down word by word with who said each, as media transcript does, and cuts it into sentences. On each it measures what is cheap to measure: where people laugh, how loud it is against the rest, a question someone else answers, how many fillers. Then the text model reads the transcript a stretch at a time with those marked, and names the moments that grab in the first three seconds and stand alone: a claim, a story, tension, a joke that lands. A last pass weighs the best against each other and says who the speakers are and how they come across. Each moment is whole sentences, from --shortest to --longest seconds (20 and 60), with its times, a title, the hook, why, a score and the mood. A sentence with one of the phrases the flags scan hears as "do not use this" ("off the record", "don't use that", "do not use that", "cut that", "don't record", "not for the video", "delete that"), and the three sentences after it, are never sent to the model and never picked. Other ways of saying it are not caught: read a recording before sending it to a hosted model. A clip never opens on a "so", a "yeah" or a reply: it starts at the next sentence that stands up. considered in the JSON lists every moment that was weighed, for a person to see what else was in the running. --save-words keeps the words so a second look need not write the recording down again. A small local model will do; a larger one, or a hosted one, is a setting.

Try a model on a few passages you know before trusting it. One that marks filler as highly as an explanation adds noise, and small ones are strict to a fault about what answers a question.

What a person decides is kept, with who decided and when. media keep and media cut rule a passage or a shot in or out, everywhere or for one episode, and media prefer records which of two was better. media script writes the best passages out as a plain document in the order they were said; mark each one and media script --read stores the marks, and saying the same thing twice stores it once. --takes PATTERN writes out the takes whose names fit, and --at-least coherence=0.55 only the passages that scored that much.

media compile chooses shots for a cut. The best shots by score are the same shot over and over, so each pick is weighed for its quality less how much it looks like what is already picked, and the picks are ordered so that neighbours differ. Every run says how alike its neighbours are beside what the top of the list would have given. A --seed makes a variant, and the same seed makes the same one. A cut is revised by reacting to its clips with media note and compiling the next one --after it. media timelines lists the cuts and media timeline shows one. --max-length leaves out shots longer than that many seconds. --remember NAME keeps a cut's settings as a selector to cut by again with --using, and --description says what it is for; media selectors lists them.

media fit teaches a model from the choices made with media prefer: which measurements of a shot go with being chosen, and by how much. It is tested on footage it was not fitted to, a whole shoot held out at a time, since shots from one shoot are alike enough to flatter a model that has seen their neighbours. The share it gets right is shown beside the half a coin would get. A model that has not beaten the coin by more than chance is stored with its figures and left unused. One that has gives every shot a preferred score, and a recipe made with media recipe can weigh it beside the rest. With several models stored, media rank RECIPE --model NAME and media compile --model NAME go by what that one model made of each shot and nothing else; the recipe still decides which shots were measured enough to be ranked at all.

media assemble makes an interview into a cut. The passages a person kept go in first, then the best by a recipe until the cut is as long as it was asked to be, and every passage passed over is counted with the reason. Each one is seen through the take's main camera, or another that was rolling, and heard through a microphone before a camera: the one measured cleanest, or failing that the one whose words the recogniser was surest of. Quiet at either end of a passage is trimmed to what the style allows; only the ends move, so a filler in the middle of a passage stays where it was said. media styles lists the stored manners of cutting, and any one setting can be given on its own. A cut made --after another keeps the clips that were kept or adjusted, with their sound still in step, and leaves out what was dropped. --takes PATTERN makes one cut from every take whose name fits, in place of --take for one or --project for all of them.

A cut filled best first is a reel of good moments, and nothing in it says why one follows another. --story has the text model choose the passages and the order they are seen in: what opens the cut, what answers what, what it ends on. The model is shown only the best passages that already suit the cut (40 of them, or --pool N), by number, and answers with numbers, so it cannot make up a moment or move the end of one, and nothing asked not to be used is sent to it. --about TEXT says what the cut is to be about. The title, the one line it is about and the reason for each clip are stored with the cut, with the model's name, and media timeline shows them. --switch sees each clip through a different camera from the one before wherever another was rolling, so two stretches of one camera never sit side by side as a jump; the sound does not move. Both lean on media sync: a camera or microphone that was never placed on the take's timeline is never cut to.

media cutaways lays other footage over some of a cut's clips while the sound carries on underneath: the middle of a long clip, or the whole of a short one, never the first. It leaves out shots with somebody filling the frame and anything recorded in the takes the cut is made from. A cutaway that was dropped is replaced by another of the same length.

media render makes a cut into a file. Every clip is given a whole number of frames counted from the start of the cut, so rounding never adds up, and the sound is cut to the same count in samples: a long cut ends as much in step as it began. Sound that carries on from one clip to the next in the same recording is read as one unbroken stretch, with no join to hear under a cutaway; where it does jump, it fades out and in over a fiftieth of a second. Each stretch is measured and brought to one loudness, with one gain for the whole of it and a limiter under a ceiling, or left --as-recorded. The picture is padded to the canvas or cropped to fill it, and a crop moves to where the people in the shot were found. It reads the small copies made at ingest unless --originals is given, and --megabytes holds the file to a size. When it is done it looks at frames through the file and says so if they are not all the size that was asked for, and the file is recorded with the recordings it was made from, so media lineage can answer for it.

A cut is made from the recording that was easiest to read, which is seldom the one that sounds best. media relink stores it again with each clip's sound moved to the same moment in another recording of its take, by the offsets media sync found: a recorder on the table in place of the camera's own microphone. A clip the recording does not cover is left as it was and listed. media render --mix goes further where people wore microphones. One microphone is right while one person talks, and when the speaker changes everyone else is heard through somebody else's. So under each stretch the take's worn microphones are mixed the way an editor rides faders: whoever is speaking is up, a little before their first word, and the others are down by --duck decibels and never off, because they carry the room and the laughter. Through a pause the last speaker stays up, and a recorder that was turned down is brought level with the rest. A stretch the microphones do not cover is left as cut, and the render says which were mixed and who led.

media export hands a cut to an editing program. It writes FCPXML, which Final Cut, Resolve and Premiere import as a timeline, the same cut as a CMX3600 edit decision list for anything else, and a page that says what both point at. Nothing is copied: the files name the original recordings where they are kept. Times are exact fractions of a second at the rate the footage was shot at, so 29.97 is 30000 frames in 1001 seconds and not a rounding of it, and each is given on the recording's own clock where it has one: the timecode a camera wrote for its first frame, drop-frame or not, and the time after midnight a sound recorder stored. A clip heard through another recording has that sound under it and the camera's own switched off. A cut whose footage was shot at more than one rate says so, and so does one that points at a recording that is not there.

A folder to send somebody is the same command: --preview adds the cut rendered small, held under --megabytes, and --renders copies in every render already made of it, and the page lists them. --title names the cut for the editing program. Before it goes, media flags lists every flag that falls inside the cut's clips, on whichever recording of the take it was heard, and says how many seconds cutting the ones marked to cut would take out; it fails if the cut holds something someone asked not to be used.

media outputs is the other way round from media lineage: every derived file on record with what it was made from, the ones whose file is gone included, and then the pictures and sound in the work folder that nothing on record accounts for. Those are what to look at before clearing a folder out. It deletes nothing.

media tidy shows where the space went: the temporary folders, and each folder of the work folder with its size. Every temporary folder the engine makes is in one place (constructive-media in the system's temporary folder, constructive-media-UID where every user shares it, as /tmp, or CONSTRUCTIVE_MEDIA_SCRATCH_DIR, a folder of your own with no spaces or quotes in its path) and named PID-WHAT-… for the process that made it. It is removed when its command is done, fails, or is stopped with Ctrl-C, kill or a closed terminal; one a command killed outright left (kill -9, the machine going down) is removed by the next command, once an hour at most, once its process is gone and the folder has not changed for ten minutes. Two folders of the work folder are caches with a cap each, 20 GB unless CONSTRUCTIVE_MEDIA_WORK_CAP_GB (or CONSTRUCTIVE_MEDIA_WORK_CAP_PROXIES_GB for one) says otherwise, off for none: proxies, the small copies of videos analysis reads, and frames, the sample frames of shots. Past the cap the least lately used go, the database rows that name them cleared first, so a video whose proxy went is read itself from then on. Nothing used or changed in the last day goes, nor a frame of a shot not yet looked for people in. After each run media ingest trims the proxies that are older than that to their cap, so a large ingest can leave the folder over its cap until a day has gone by. The rest is kept, and media tidy says why: a recording's sound copy (sound) is what is heard once the recording is let go to the cloud, and renders and what a model made are recorded as assets. media tidy --yes removes what ended commands left and trims each cache to its cap, and says how much it gave back; --json prints the same as JSON. CONSTRUCTIVE_MEDIA_SCRATCH_KEEP=on leaves every temporary folder where it is, to look into, until media tidy --yes.

Where things go

Temporary folders go in the scratch folder (tmp), and whatever can be made again goes in the work folder (cache): proxies, frames, sound copies, and spaces, one folder for each piece of work. Models, libraries and the database are data and are never let go of. docs/STORAGE.md has the whole map.

cd "$(media space harbour-shorts --note "three shorts from the harbour talk")"
export CONSTRUCTIVE_MEDIA_SPACE=harbour-shorts   # render, export, pull, audition, ab, eval with no --out write here
media spaces                                     # what is being worked on, latest first

media space NAME makes spaces/YYYY-MM-DD_NAME/ in the work folder (or reuses the newest of that name) and prints only its path; its space.json says what it is, who made it and what wrote into it (media generate keeps writing to the work folder's generated). Spaces are cache, in appstash's storage format: media tidy --yes lets the least lately used go past their cap, never one kept by hand (--keep), one holding review verdicts or any file the engine did not write as it is (a hand-edited script, a recording made by hand), one used in the last day, or one adopted where it already was (media space --adopt PATH).

media train teaches the picture model a face, a thing or a manner from fifteen to forty photographs, and media generate image ... --like NAME makes a picture with what it learned; docs/ADAPTERS.md has how long it takes and what the photographs should be. A face is somebody's: who said it may be learned is asked every time and kept beside it.

media generate hands a description to a model and keeps what it makes apart from what was filmed. image is filled by mflux running FLUX.2 klein, video by Wan through diffusers, audio by MOSS-SoundEffect through mlx-speech and music by ACE-Step, all on your own machine and all installed by you; docs/ADAPTERS.md says how, and how long each takes. Every request is a row, with its words, model, settings and seed, whether it worked or not, and media generations lists them, or adds them up with --spend. The same request is made once: asked again, the command prints the file it has, and --again makes another with a seed of its own. --from starts from a picture: for video, that is a still made to move, which takes the ltx adapter from media-engine-plugins (--adapter ltx), whose model has terms of its own. --max-usd refuses a request its maker prices above that, and --dry-run makes nothing. An adapter for a service that takes minutes is handed the request and media collect brings in what it made, asking again for as long as --wait SECONDS allows while anything is still to come. What is made is a derived file of the kind generated, so media lineage answers for it, and media synthetic lists the clips of a cut whose picture or sound a model made. It fails when there are any: the question to ask before a cut is shown as a record of what happened.

media persona records who somebody is: a real person or an invented character, and a few words about them. media personas lists everybody with the voices found in recordings that were named as theirs and the voices that can speak as them.

media conv reads scripts in the .conv format: who speaks, what they say, and the sounds and music under them. It reports everything wrong in a script at once, each problem with its line, what is wrong and the nearest thing that would be right, and --json prints the scene the script describes. @include NAME finds NAME.sounds in a banks folder beside the script, or wherever --banks says. The reader passes the format's own conformance files, which are kept in tests/fixtures/conversation-format, and it runs no model.

media say renders a script. Everybody who speaks needs a voice (media voice), and a server that speaks and a model that listens need to be set up; see docs/ADAPTERS.md. To hear a script before you have a speech model, examples/mac-voice-server.py answers with a Mac's own voice, and examples/scene.conv is a scene to try. Each line is said, listened back to and checked against its words, and said again with another seed until a take passes. Sounds are files the script names, looked for beside the script or in the folders given with --sounds. The mix is turned up or down whole to -16 LUFS, and squeezed only if its peaks would otherwise pass -1.5 dB. Beside out/scene.flac are kept:

out/scene.lines/line_001.wav    every line as it was said
out/scene.stems/dialogue.wav    each track on its own, with --stems
out/scene.words.json            every word, with when it was said, as the script spells it
out/scene.manifest.json         each line's seed, takes and verdict, and where everything landed

The words are timed by what was heard when each line was checked, so a render is never heard again to be captioned: scene.words.json is the words file media captions --words and media shorts read, and each word in it says its line and who said it.

A line no take of which passed is kept in the scene, marked needs_review in the manifest and put in media_audio.review_queue for a person to listen to. A take is also judged by its sound. A line that stops in the middle of a word is still speech in its last twentieth of a second (above -36 dB after a tenth of a second of speech, the digital silence a model pads it with left out), and is said again with another seed, a line of a few words as much as a long one; one word alone may end loud. A line that passed can still be worth an ear, and its listen in the manifest says why: an ending between -45 and -36 dB, which may or may not be a word cut short, or a pause of a fifth of a second or more between two words with nothing written between them. Where a pause falls is taken from when the words were heard and can be a word out, so neither is a reason to say a line again: media say names the lines and leaves them to whoever listens, and media say --voice says the same of the words it was given, on a line under the one that says how they came out. Those levels suit the voices the engine is used with. A voice model that speaks much quieter or louder is given its own, with no change to the code: CONSTRUCTIVE_MEDIA_LISTEN_STOPPED_DB (-36), CONSTRUCTIVE_MEDIA_LISTEN_UNSURE_DB (-45) and CONSTRUCTIVE_MEDIA_LISTEN_SPEAKING_DB (-40) for an ending, and CONSTRUCTIVE_MEDIA_LISTEN_PAUSE_S (0.2) and CONSTRUCTIVE_MEDIA_LISTEN_PAUSE_DB (-45) for a pause. They are levels of the take as the voice made it, before the mix is brought to its loudness, and a line kept by --keep or --only keeps the notes it was given. An echo or a room put on a line rings on under whatever follows: the next line comes in when the words end. media say scene.conv out/scene.flac --only ada,7 says again just one persona's lines and line 7, and keeps every other line as it was; --keep says none again, for when only the music or the sounds have changed. Either still says a line whose words, breaks, seed, emotion or speed have changed, or that a layer now says differently.

A voice sets its own pace, and speed: changes it: speed: 0.9 on a character, ADA[speed:0.9]: ... on a line or {speed:0.8: these words} inside one says them that much of the voice's own pace, from 0.5 to 2, and media say scene.conv out/scene.flac --speed 0.9 is for every line that names none. The nearest one wins, and with none written nothing changes. A voice that can be told how fast to speak is told; any other is stretched in time with its pitch kept, before the line is listened back to, so what is checked is what is heard. A speech model often says a long line faster than a short one: --sentences says a line of several sentences a few at a time, each piece gathered to 25 words (--sentences 40, or --sentences 1 for every sentence by itself). The manifest gives each line's wpm, the words a minute it came out at, and under pace the middle of them and the lines more than a fifth away from it, which media say also prints. A line asked to be slower or faster is not far from the others for that: the speed asked of its words (the line's speed in the manifest, when it is not 1) is divided out of its pace before it is held against theirs. A quiet in such a line is longer or shorter by as much, so how long one must be to be noted as a pause is divided by the speed too.

The voice is handed each line through layers, which lay how it is said over what it says and leave the script as it was written: numbers says "2016", "$3.50", "70+%" and "3-5" as they are said aloud, web reads out "example.com", and acronyms spells "FAQ" as F A Q and leaves "NASA" and a shouted "NO" alone. Those three are on; tech-words and fillers are there to switch on with --layers, and so is a project's own word list, a .json of what a transcriber misheard (heard, the shape media mend keeps), how words are said (say) and capitals said as words (keep). media say scene.conv --dry-run prints every line that would be said differently, and says nothing. The manifest keeps what each line was given as spoken, and the check compares what it hears with that.

One word in one line can be written both ways in the script, as it is shown and as it is said: ADA: Our {CVSS|C V S S} score fell {19x|nineteen times}. is said with "C V S S" and "nineteen times", and its captions on the stage show "CVSS" and "19x". 1.5{M|} is shown and not said. The manifest keeps each line as said (text) and, where it differs, as shown (shown).

A sound described by a prompt: is made from its words by whatever fills the audio slot, once, and kept (docs/ADAPTERS.md); pass --without-generated to leave such sounds out.

A render keeps every line as it was said (out/scene.lines) and, with --stems, each track on its own (out/scene.stems). They are what --only and --keep work from and what you listen through, and they are most of what a render weighs. When a render is done, media purge out shows what every render under a folder kept and how much it weighs, and media purge out --yes takes it away. The rendered file and its manifest stay. A render whose output is gone is left alone, and so is one with a line still waiting to be listened to, unless --unreviewed. Afterwards, saying the script again says every line again.

The same engine from Python:

from constructive_media import conv, effects

effects.apply("line.wav", "line-wet.wav", effects.Effects(reverb="hall", gain=-3))
scene = conv.load("scene.conv")    # or conv.parse(text); ConvError lists every problem

from constructive_media.audio import scene as scenes

report = scenes.render("scene.conv", "out/scene.flac", stems=True)   # the manifest, as a dict
scenes.record(report)                                                # the render, its lines and what to listen to

A rendered script is filmed by a page that follows it. A script's [slide …], [speakers …] and [video …] marks say what is on the screen (<slide …> inside a line puts one in the middle of a sentence); the page is the built-in one, or any HTML of your own:

media film out/scene.flac out/scene.mp4                 # the speakers and what they say
media film out/talk.flac  out/talk.mp4 --page examples/talk  # a deck that follows the talk
media film out/talk.flac  out/talk-clean.mp4 --page examples/talk --clean  # nothing of the speakers drawn, to cut shorts from
media still out/talk.flac out/stills --page examples/talk    # pictures of it at moments of the talk, in seconds
media stage out/talk.flac --page examples/talk          # the same in your browser, to scrub through

Decks, documents that scroll with the voice, and walkthroughs with a pointer are in docs/STAGE.md. It needs a Chrome or Chromium that is already installed.

A voice can be one the speech server has, or one cloned from a short clip of a voice you have the right to use:

media clean recording.wav              # is it clean enough to clone from, and what would mend it
media reference recording.wav voices/ada/neutral.flac --from 12.5 --to 34 --listen
media voice ada ada --reference voices/ada/neutral.flac --new
media say --voice ada "The lantern is lit at dusk." out/line.wav
media audition ada
media eval speech --voice ada             # the speech adapter scored on lines whose words are known
media fillers talk.mp4 out/fillers         # ums, stutters and restarts cut out; edit out/fillers/script.txt and run again with --script
media captions talk.mp4 talk-captioned.mp4 --save-words talk.words.json   # the words drawn on it as they are said
media ab talk.mp4 talk-cleaned.wav --at 1:01.2 --name "the s in the name"  # old, beep, new, matched in loudness: the-s-in-the-name.mp3

Two ways of one sound are judged best a few seconds at a time, one straight after the other: media ab writes the old way, a beep and the new way, at most ten seconds in all, both at one loudness so the louder is not heard as the better, and names the file for what to listen for.

On a Mac the speech can come from a model run in the engine's own process, with no server: pip install mlx-audio and CONSTRUCTIVE_MEDIA_ADAPTER_SPEECH=mlx (docs/ADAPTERS.md). With that adapter two voices can be made into a third, heard, and kept as a voice of its own (docs/VOICES.md):

media blend ada:0.35 grace:0.65 out/between.wav
media blend ada:0.35 grace:0.65 voices/wren/neutral.wav --keep wren

A model that clones takes seconds over a sentence. For talking there is a small one that takes a tenth of a second and speaks in voices of its own, and they can be mixed until they lean towards a recording. It is the same sort of voice and not a clone (docs/VOICES.md):

media mimic ada.flac voices/little-ada.safetensors --keep "Little Ada"
media talk --voice little-ada

A recording can be said again in another voice, its words and their timing kept. That takes a model the engine does not hold: a plugin fills the voice_conversion slot (docs/VOICES.md):

media revoice take.wav out/take-as-ada.wav --voice ada
media talk --voice ada --quick af_heart     # a quick voice, said again in a cloned one

A video whose sound is poor can have its dialogue replaced: each person said again in a clean voice, a persona's or one cut from the recording, with the words and timing kept so it still matches the picture. It writes a converted and an original stem for each person, all starting at the same moment, and the picture with the new sound (docs/VOICES.md):

media transcript talk.mp4 talk.conv
media adr talk.mp4 talk.conv adr/ --voice VOICE1=ada --voice VOICE2=guest.wav

A voice with music under it can be taken out from over the music. That is a model's work too, and a plugin fills the separation slot with one whose weights are for research (docs/VOICES.md):

media separate interview.wav parts          # parts/voice.wav, parts/rest.wav

A face in a piece of video can be made to say a recording. That is a model's work as well, and a plugin fills the lip_sync slot with one whose face models are for non-commercial research (docs/ADAPTERS.md). Use a face that is yours to use: one a model made, or one whose owner said yes to the words.

media lipsync face.mp4 line.wav out/face-says-line.mp4

The models that listen, write and speak can hold a conversation between them. What you say is written down, answered and said back, a sentence at a time, and it stops when you speak over it:

media talk --voice ada     # prints an address on this machine; open it and speak
media talk --measure       # how long each model takes, and the wait they add up to

It is in docs/TALK.md.

That is docs/VOICES.md. Voices, banks of sounds and faces that are meant to be shared live in a repository of their own, a library, where every voice carries its consent:

media library add owner/lighthouse-voices
media library voices lighthouse
media library clip ada recording.wav --by "Ada Marsh" --kind own    # in a library of your own: put a voice in

That is docs/LIBRARIES.md.

A project of your own starts from a template:

media init workspace harbour-talks     # a pnpm workspace with a first deck in it
media init deck quarterly-review       # another deck, in its packages/

The templates are in media-engine-boilerplates, in the format pgpm init reads, and you can point it at your own. That is docs/PROJECTS.md.

Settings are environment variables that start with CONSTRUCTIVE_MEDIA_; they are listed in settings.py.

Run the tests and the checks CI runs:

pnpm test                          # each module, in a throwaway database
pgpm test-packages --full-cycle    # deploy, verify, revert, deploy again
pnpm run audit:db                  # schema audit (security and performance)
PYTHONPATH=python python -m unittest discover -s tests -t .

The Python tests make their own media with ffmpeg and skip what your machine cannot run. Those that touch the database run when CONSTRUCTIVE_MEDIA_TEST_DATABASE_URL names a database with the modules deployed, and roll back everything they do.

Licensing

Everything in this repository is MIT licensed, and it stays that way:

  • Code here is MIT. Dependencies are MIT, Apache-2.0 or BSD, and a test fails the build on one that is not.
  • No copyleft code or dependency (GPL, AGPL, LGPL, MPL) is added here. An adapter for anything else is a plugin, a package of its own in another repository, and the engine works without any of them.
  • ffmpeg, whisper.cpp and PostgreSQL are programs the engine runs, not code it contains. They keep their own licenses and you install them yourself.
  • No model weights, voices, audio or footage are committed. A model's license applies to whoever downloads and runs it.

The full rule is in docs/LICENSING.md, and every model the engine knows by name, with its source and its license, is in docs/MODELS.md.

Related

  • conversation-format: the .conv screenplay format for multi-voice audio. This engine is an implementation of it: it reads a script and renders it. The grammar, the reference parser and a skill for writing scripts are there.
  • media-engine-plugins: optional adapters, each a package of its own that you choose to install.
  • media-engine-boilerplates: what media init starts a project from: a pnpm workspace, and what goes in one. A narrated deck, a walkthrough, an animation, and a document that is read aloud, filmed as it scrolls, and printed: each a script and a page that media film turns into a video. And the template for a library of voices, sounds and faces in a repository of your own: media init library NAME.
  • pgpm: the Postgres package manager the schema modules are built with.

Developing

Auditing

safegres grades the schema this workspace deploys on two independent axes — security (grants, RLS, policy coverage and behavior) and performance (predicates no index can serve, per-row function calls, foreign keys without a covering index). It runs from the workspace root and needs no configuration per module: every module under packages/ is deployed into one ephemeral database and that catalog is scanned, so a module joins the audit the moment pgpm init creates it.

# Audit: deploys every module into an ephemeral database and scans its catalog
pnpm run audit:db

# Accept today's performance findings as debt, so CI gates only on new ones
pnpm run audit:db:baseline

# Audit a database you already have instead
pnpm exec safegres audit --database your_db

The gates and the exposed surface to grade against live in safegres.config.js; the run also writes JSON, markdown and SARIF reports to safegres-reports/. safegres-perf-baseline.json is committed — it is the accepted performance debt (today, only unscored notes about unindexed timestamp columns), and the only audit file that carries state. CI runs the same audit as a single Database audit (safegres) job.

Declaring exposure in the config is the first thing worth doing: until the audit knows which schemas and roles your API reaches it has to assume the whole database is, and caps the score at the B the gate allows.

Using your own PostgreSQL

pgpm docker start is a convenience, not a requirement. If PostgreSQL (17+) is already running on your machine, point pgpm at it and carry on — nothing else changes:

export PGHOST=localhost PGPORT=5432 PGUSER=postgres PGPASSWORD=yourpassword
pgpm admin-users bootstrap --yes   # once: creates the roles pgpm and tests expect

Don't run eval "$(pgpm env)" in that case: it prints the Docker container's defaults (postgres/password on localhost:5432) and would overwrite yours. If you want the Docker container alongside an existing server, give it another port and match it: pgpm docker start --port 5433 then export PGPORT=5433.

Install scripts

pnpm install never asks you to approve build scripts here: every dependency that wants to run code at install time already has a decision in pnpm-policy.yaml. If a new dependency stops the install with ERR_PNPM_IGNORED_BUILDS, add it there — under allowBuilds with a reason if it truly needs its script, or as false if it does not — and run pnpm run policy. Don't use pnpm approve-builds; it writes outside the managed block and pnpm run policy:check will fail.

Working with an AI agent

Two skills are in .agents/skills/. .agents/skills/constructive-media/ is how the engine is used: setting it up, taking a .conv script to sound, taking footage to a cut, and what to do when something goes wrong. Install it where your agent looks with:

npx skills add https://github.com/constructive-io/media-engine --skill constructive-media

pgpm init workspace installed the pgpm skill at .agents/skills/pgpm/ — a guide to pgpm's commands, the deploy/revert/verify pattern, plan files, dependencies, testing, and CI. Agents that read .agents/skills/ (Codex, Cursor, Gemini CLI, opencode, ...) pick it up automatically; see AGENTS.md.

For an agent that looks elsewhere, either point it at .agents/skills/pgpm/SKILL.md directly, or install the skill into the location it expects:

npx skills add https://github.com/constructive-io/constructive --skill pgpm

Prerequisites

  • Node.js 22+
  • pnpm
  • Docker, or a local PostgreSQL 17+ you have superuser credentials for
  • PostgreSQL client tools (psql)
  • pgpm (npm install -g pgpm)

See Prerequisites for detailed setup instructions.

📚 Agent skills

  • Media Engine skills: teach Claude Code or another coding agent to render scripts, stage video, and work with media libraries.
npx skills add constructive-io/media-engine

Constructive Media ecosystem

Render scripts to audio and video, mix sound, and assemble footage into cuts.

🚀 Starters and related projects

📦 Key packages

  • constructive-media: the Python engine and the media CLI.
  • media-core: personas, voices, assets, takes, and provenance.
  • media-video: shots, transcripts, timelines, and editing decisions.
  • media-audio: speech synthesis, renders, and review.
  • media-image: photographs, their dates and faces, and every file moved.

Credits

🛠 Built by the Constructive team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on GitHub.

Disclaimer

AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.

No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.

About

One engine for video, images, audio and voice, with Postgres as its memory

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages