The Librarian
The Librarian — parts catalog & cut assembler
Runbook step 7, built & verified 2026-07-08. Replaces hand-maintained concat.txt files.
What it is
Two scripts in C:\AI turn the 63 loose render parts into a queryable library and
make new cuts a one-line command.
librarian.py— scans the ComfyUI output dir, reads the workflow ComfyUI embeds in
each mp4's prompt metadata tag, and recovers full provenance per part. Writes
catalog.json. Provenance is deterministic, not guessed: the embedded
VHS_LoadImagesPath directory (sNNrM_c) gives source segment+run; the positive
CLIPTextEncode gives style+content; loader nodes give the model stack; the sampler
gives seed/steps/cfg. Recovered fields: segment, run, style, positive prompt, model,
lora+weight, controlnet type/strength/end, seed, steps, cfg, sampler, frames, fps,
resolution, duration, version.
assemble.py— turns a cut file (JSON EDL) into a finished mp4: concat parts in
order, remux the original source audio.
Files
catalog.json(this folder) — the machine-readable index. Regenerate anytime withlibrarian.py.cuts/.json— cut files (EDLs).cuts/.mp4— assembled masters.
Cut file schema (cuts/<name>.json)
{
"name": "v1_full",
"audio": "~/Downloads/e_studios_source.mp4",
"parts": ["RUNTMP_00005", "RUNTMP_00006", "..."]
}
audio optional (defaults to the source). parts is an ordered list of part_ids;
each resolves to a path via catalog.json (fallback: OUTDIR/<id>.mp4).
Commands
python librarian.py --print # rebuild catalog.json + human table python librarian.py --query segment=21 # filter catalog (no rescan): see a segment's version stack python librarian.py --query style=ligne model=LTX # ints match ==, strings match substring; combine freely python assemble.py cuts/v1_full.json # build a cut python assemble.py --from-concat v1full/concat.txt v1_full # import a legacy concat -> cut json python assemble.py --new-v1 v1_from_catalog # regenerate the v1 EDL from catalog metadata alone python assemble.py --swap v1_full v1_lignev4 seg21=LIGNE_V4_00001 # clone a cut, swap part(s), assemble python librarian.py --gaps # per-segment version count; the re-render queue
--swap keys are segNN (must be unique in the cut) or an existing PART_ID; multiple pairs allowed
in one call (audition several upgrades at once). This IS the "new cut in seconds" loop:
--query to find the part → --swap to drop it in.
Verified
assemble.py cuts/v1_full.jsonreproduces the shipped master exactly: 40.099002s = 40.099002s.--new-v1(catalog metadata only, no concat file) produces the identical 47-part ordering.
→ the concat.txt files are now redundant; the catalog is the source of truth.
How to make a new cut (the "in seconds" promise)
- Render a new part (any pipeline) → it lands in OUTDIR with its workflow embedded.
python librarian.py→ it appears in the catalog, provenance auto-recovered.- Copy a cut json, swap the part_id for the segment you're replacing,
assemble.pyit.
e.g. to swap seg21 to the v4 ligne claire: replace RUNTMP_00030 with LIGNE_V4_00001.
Coverage notes
- 63 parts cataloged, all 63 with recovered workflow; 56 mapped to segment/run, 61 to style.
- 7 "ext" parts (no segment): the LTX/Cog taste tests and early seg02/seg03 experiments —
correctly outside the 38-segment scheme.
- Model axis distinguishes: SD1.5+AnimateDiff (v1 stack), +LoRA, +IPA, lineart-CN vs canny-CN,
LTX-Video-2B. As cloud parts (Qwen/Wan) arrive with their own embedded or sidecar metadata,
extend parse_workflow/PREFIX_HINT in librarian.py.
Existing cuts (cuts/)
v1_full— the shipped v1 master, imported from the legacy concat (40.099s).v1_from_catalog— proof cut: identical v1, regenerated from catalog metadata alone.v1_lignev4— v1 with seg21 swapped to the ligne claire v4 lineart part (LIGNE_V4_00001).
Note: v4 was rendered on seg21's bass-macro frames, so this is a "v1 + ligne v4 upgrade"
demonstration at seg21, not the post-swap casting.
v1_cast— the first casting-accurate cut. The decided seg09↔seg21 swap made real:
seg09 = LIGNE_S09_00001 (ligne claire Palantir, wordmark legible), seg21 = CONSTRUCT_S21_00001
(constructivist bass macros). The film as designed in E_CASTING.md, not as first-drafted.
Base for cloud upgrades → the maximal version.
Next (when wanted)
- Per-part sidecar
.jsonfor the non-ComfyUI parts (Cog diffusers, cloud renders) so their
provenance is as rich as the ComfyUI ones.
--querysort/format options and a--gapsmode (segments with only a v1 part, no upgrade yet).