--- name: extracting-brand-kits description: >- Use when the user says "make my video look like THIS" with a reference video, screenshots, or a moodboard — build a CueFrame brand kit FROM that inspiration so every subsequent compose speaks its visual language. Owns the extraction step: sample the reference's graphics-bearing frames, upload them as exemplars, reproduce each recurring motif as an authored graphic verified against the reference, and upsert the kit with the full language payload. Triggers on "match this style", "like this reference", "use this video as inspiration", "extract a brand kit", "moodboard". Hand off to cueframe-storyboard/composing-video once the kit is bound. --- # Extracting brand kits: reference pixels → a kit the engine honors Use the [project and capability policy](../composing-video/references/project-policy.md) for scope, current state and metered work. ## The one idea **No summarization anywhere in the path.** A reference described in prose converges on house style with the reference's palette — the pixels are the ground truth. You (the agent) are the extractor: you SEE the reference, curate its frames, and reproduce its motifs as ordinary authored graphics, verified against the reference by looking. The kit you produce carries (a) **exemplar frames** the compose maker and judge both see, and (b) **motif skins** — card HTML the designer reproduces — plus code-checked facts (caption profile, density, palette). Once bound to a project, the engine takes over: the planner plans to your density, the designer sees your exemplars (`view_style_reference`), the judge grades every candidate against them, and a half-applied kit fails the compose loudly instead of shipping house style. Everything below drives the public `/v1` API with your API key. Frames never pass through chat — they go straight to storage via presigned PUTs. ## 0. Prereqs - An API key with `projects:write`. `create_brand_kit` gates on the `brand_kits` entitlement, which EVERY plan grants including free, and it costs no credits — so brand kits are not a paywall to route around. (`get_account` confirms it; a 402 names the feature.) - `ffmpeg` locally, and the reference video file (download it first if it's a URL). - Know the org's IDENTITY kit if one exists (`get_profile` → brandKits). Inspiration NEVER overwrites identity: logo, brand fonts, and identity color slots come from the existing kit (or stay for the user to fill) — extraction contributes the LANGUAGE only. ## 1. Sample the reference (local, ffmpeg) Uniform sampling misses short-lived graphics (1–3s overlays). Sample two ways and union: ```bash # scene cuts ffmpeg -i ref.mp4 -vf "select='gt(scene,0.22)',showinfo" -vsync vfr scenes/%03d.jpg # 2fps sweep (catches overlays that appear without a cut) ffmpeg -i ref.mp4 -vf fps=2,scale=720:-1 -q:v 4 sweep/%04d.jpg ``` Then LOOK at the frames and curate: keep the **graphics-bearing** ones — frames where a card, pill, stat, lower-third, caption treatment, or end-card is visible and sharp. Drop near-duplicates. **≤24 frames**, each downscaled to ≤720px width, jpeg. For each animated graphic, also note the timestamp where it ENTERS (you'll classify its motion in step 5; re-watch that 1s window at `ffmpeg -ss -t 1 -i ref.mp4 -vf fps=12 burst/%02d.jpg` if you need to see the entrance). Optional but recommended: build a contact sheet for the human's "right vibe?" check: `ffmpeg -i frames/frame-%02d.jpg -filter_complex tile=6x4 sheet.jpg`. ## 2. Upload the exemplars (the ingest door) ``` POST /v1/brand-kits/exemplar-uploads { "count": , "includeContactSheet": true } ``` Returns presigned PUT slots under the org's `brand-inspiration/…` prefix — the ONLY namespace the kit door accepts exemplar keys from. PUT each curated frame (order matters: frame-01 ↔ index 0 — motif `evidence` arrays reference these indexes), PUT the sheet, keep the returned `key` list. URLs expire in 15 minutes; re-POST for a fresh batch if you run over. ## 3. Inventory the motifs Look across the exemplars and list every RECURRING graphic treatment (expect ~5–12 for a designed reference). For each, write: - `id` — `m1`, `m2`, … - `observed` — one precise sentence ("thin-outline rounded keyword pill, single word, beside subject"). - `role` — the closed vocabulary the planner/designer speak (exact values): `title-card | stat | lower-third | pull-quote | hero | logo-tag | enumeration | sequence | comparison`. Pick the role each motif best SERVES — the designer's steering matches on it exactly. - `evidence` — the exemplar indexes (0-based) it appears in. - `zone` — normalized `{x, y, w, h}` where it lives. - Behind-the-subject motifs (text the speaker occludes): record them with `coverage: "skipped"` and `skipReason: "behind-subject — card graphics render front-only"`. Do NOT attempt them. Also read the CAPTION treatment off the frames (step 6 consumes it): plate or plateless? base/ highlight colors? case? emphasis styling? entrance feel (~ms)? ## 4. Reproduce each motif as a card (author → look → refine, ≤3 iterations) For each non-skipped motif, author it as a **card** (freeform HTML/CSS — rendered verbatim) and verify it against the exemplar BY LOOKING: 1. **Measure first**: read the exemplar — border weight, radius, padding, font size relative to frame, colors. Measurement-seeded CSS gets you ~90% in one shot. 2. Author `{ "kind": "card", "html": "…", "tokens": { … } }`. Bind every brand-swappable color through `tokens` with `$brand:` refs (e.g. `"line": "$brand:colors.accent"`, referenced in CSS as `var(--cf-line)`) so the kit's identity re-themes it. No `