Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat(music-video): word-by-word hook typography (build template)

[._.]/ Adam Eivy34510c4e5cd0
diff --git a/client/src/components/musicVideo/TypographyPanel.jsx b/client/src/components/musicVideo/TypographyPanel.jsx
index 2d45026f5d..3bc2ca5ade 100644
--- a/client/src/components/musicVideo/TypographyPanel.jsx
+++ b/client/src/components/musicVideo/TypographyPanel.jsx
@@ -7,7 +7,7 @@ const toSec = (value) => (value === '' ? null : Number(value));
const inputCls = 'bg-port-bg border border-port-border rounded px-1.5 py-1 text-xs min-h-[44px] sm:min-h-0';
// Mirrors the server's composition enums (server/lib/musicVideoValidation.js).
-const TEMPLATES = [['fade', 'Fade'], ['rise', 'Rise'], ['typewriter', 'Typewriter'], ['pop', 'Pop']];
+const TEMPLATES = [['fade', 'Fade'], ['rise', 'Rise'], ['typewriter', 'Typewriter'], ['pop', 'Pop'], ['build', 'Word build']];
const PLACEMENTS = [['lower', 'Lower'], ['center', 'Center'], ['upper', 'Upper']];
const EMPHASES = [['subtitle', 'Subtitle'], ['hero', 'Hero']];
const FONTS = [['sans', 'Sans'], ['serif', 'Serif'], ['mono', 'Mono']];
diff --git a/docs/features/product-surfaces.md b/docs/features/product-surfaces.md
index 761dcc1a00..db6727c019 100644
--- a/docs/features/product-surfaces.md
+++ b/docs/features/product-surfaces.md
@@ -110,7 +110,7 @@ An end-to-end creative production suite for authors, worldbuilders, filmmakers,
| **SongBook** | `/songbook` | Interactive chord charts, guitar tablature, lyric repertoire, and auto-scrolling practice sheet music. | — |
| **Creative Director** | `/creative-director` | Multi-scene episodic video production orchestrator: turn briefs into treatments, storyboards, render plans, and completed episodes. | — |
| **Creative Commissions** | `/creative-commission` | Standing briefs and scheduled/nightly autonomous media generation aligning with personal taste profiles and feedback. A universe and/or mood board can be picked as the style source: each run loads its style tags and reference images as the Creative Director's art-direction base, attaches those images to vision scene evaluation, and conditions local image renders on them. | — |
-| **Music Video Studio** | `/music-video` | A project opens on seven deep-linked stage tabs (`/music-video/:projectId/:stage` — `setup`, `cast-sets`, `board`, `produce`, `compose`, `review`, `publish`; a bottom tab bar on a phone) under a sticky header showing its progress, paid-generation spend against the cap, and the one next action for the stage it is in; the composition preview (or, without a composition document, the latest draft excerpt) is docked beside the Board, Compose and Review tabs, and scene cards seek it. Audio-reactive video creation, beat-detection synchronization, scene choreography, tempo alignment, and audience-driven pre-production treatments that direct each shot. Scenes are cutaways or lip-synced performance shots; a performance shot renders only on a verified source-audio provider (fal.ai MiniMax H3 lip-sync, 5–14.8s song slices placed at an exact edit in-point, cut from an optional full-length vocal stem when one is attached — uploaded, or separated from the song with a locally installed demucs) — Grok video is cutaway-only. The autopilot kickoff analyzes the song, imports the linked track's lyric sheet (its `[Verse]`/`[Chorus]` headers and stage directions kept as lyric markers that name the analysis sections and steer shot framing), separates the vocal, aligns every word with local whisper.cpp (large-v3-turbo, downloaded on first use), builds a Cast & Sets check-in (one creative-direction call that interprets the song, then a canonical character sheet, expression and looks sheets, one empty plate per set and in-set tests on the image queue, each later image conditioned on the character sheet; assembled into a self-contained sheet saved as a development artifact), stops for the director's review unless the brief auto-approves it, then plans against the approved references. Development artifacts (check-in sheets, animatics, treatments, storyboards; HTML/Markdown/MP4/PNG/JPG) are versioned per project, reviewed with notes and approve/request-changes, and viewed in a sandboxed viewer at `/music-video/:projectId/:stage/dev/:artifactId` (the stage-less `/music-video/:projectId/dev/:artifactId` still opens it). Draft excerpts are reviewed and selectively revised by hand, or by an opt-in auto-review run bounded by director-set review and paid-generation limits (a frame-only look never passes motion or audio sync). A server-owned production run (`/api/music-video/:id/production-runs`, #9066) plans an empty board, generates missing frames and clips only on a director-allowed image/video provider+model pool, hands the continuous draft to auto-review and dispatches its revisions — within explicit generation, review and (priced routes only) dollar limits, without the browser open, and never resuming on its own after a restart; the song is the sole audio unless a sound-design bed is explicitly chosen to mix under it. A footage or composed render can intercut (#9290): shots are re-cut on the song's section energy (every 2 beats in the loudest quarter, up to every 8 in the quietest) and on sung word onsets, alternating the host shot — a lip-synced take stays in sync — with unshown footage from a cutaway in the same section, so the edit gets faster without generating more clips; an autopilot production run defaults to it unless the director chose one cut per shot. Draft excerpts can be re-framed as vertical or square social cuts with faded audio edges, from suggested hook windows (#9280). The Publish stage (#9281) builds a release kit from the final render: an X-sized 1080p, a 720p preview, a hook teaser, thumbnail candidates, lyric captions (SRT) and YouTube chapters. It also drafts every platform's copy in one director-triggered provider call from their own making-of notes, and every field stays editable. Posting (#9282) fills each platform's post (YouTube, Suno, an X thread, Shorts, TikTok, Instagram Reels, Reddit, Stacker News) in a new PortOS Browser tab with the director's signed-in sessions, shows a screenshot and summary of the filled draft, and posts only when the director presses Post for that draft; the posted links are kept on the project. Platforms are opt-in (#9287): a "Where you post" list turns each one on (all start off) and optionally names the account posted as — X and Reddit drafts filled while signed in as someone else are refused. Copy is drafted and posts are offered only for enabled platforms. Each post (including one recorded by hand) can be rated good, mixed or poor with notes; ratings roll up per platform across projects and are passed to later copy drafts. | — |
+| **Music Video Studio** | `/music-video` | A project opens on seven deep-linked stage tabs (`/music-video/:projectId/:stage` — `setup`, `cast-sets`, `board`, `produce`, `compose`, `review`, `publish`; a bottom tab bar on a phone) under a sticky header showing its progress, paid-generation spend against the cap, and the one next action for the stage it is in; the composition preview (or, without a composition document, the latest draft excerpt) is docked beside the Board, Compose and Review tabs, and scene cards seek it. Audio-reactive video creation, beat-detection synchronization, scene choreography, tempo alignment, and audience-driven pre-production treatments that direct each shot. Scenes are cutaways or lip-synced performance shots; a performance shot renders only on a verified source-audio provider (fal.ai MiniMax H3 lip-sync, 5–14.8s song slices placed at an exact edit in-point, cut from an optional full-length vocal stem when one is attached — uploaded, or separated from the song with a locally installed demucs) — Grok video is cutaway-only. The autopilot kickoff analyzes the song, imports the linked track's lyric sheet (its `[Verse]`/`[Chorus]` headers and stage directions kept as lyric markers that name the analysis sections and steer shot framing), separates the vocal, aligns every word with local whisper.cpp (large-v3-turbo, downloaded on first use), builds a Cast & Sets check-in (one creative-direction call that interprets the song, then a canonical character sheet, expression and looks sheets, one empty plate per set and in-set tests on the image queue, each later image conditioned on the character sheet; assembled into a self-contained sheet saved as a development artifact), stops for the director's review unless the brief auto-approves it, then plans against the approved references. Development artifacts (check-in sheets, animatics, treatments, storyboards; HTML/Markdown/MP4/PNG/JPG) are versioned per project, reviewed with notes and approve/request-changes, and viewed in a sandboxed viewer at `/music-video/:projectId/:stage/dev/:artifactId` (the stage-less `/music-video/:projectId/dev/:artifactId` still opens it). Draft excerpts are reviewed and selectively revised by hand, or by an opt-in auto-review run bounded by director-set review and paid-generation limits (a frame-only look never passes motion or audio sync). A server-owned production run (`/api/music-video/:id/production-runs`, #9066) plans an empty board, generates missing frames and clips only on a director-allowed image/video provider+model pool, hands the continuous draft to auto-review and dispatches its revisions — within explicit generation, review and (priced routes only) dollar limits, without the browser open, and never resuming on its own after a restart; the song is the sole audio unless a sound-design bed is explicitly chosen to mix under it. A footage or composed render can intercut (#9290): shots are re-cut on the song's section energy (every 2 beats in the loudest quarter, up to every 8 in the quietest) and on sung word onsets, alternating the host shot — a lip-synced take stays in sync — with unshown footage from a cutaway in the same section, so the edit gets faster without generating more clips; an autopilot production run defaults to it unless the director chose one cut per shot. Lyric lines sung two or more times are hooks: the treatment's text cues give them a word-by-word build (#9291) — each word lands on its sung onset in heavy caps, the newest in the accent color. Draft excerpts can be re-framed as vertical or square social cuts with faded audio edges, from suggested hook windows (#9280). The Publish stage (#9281) builds a release kit from the final render: an X-sized 1080p, a 720p preview, a hook teaser, thumbnail candidates, lyric captions (SRT) and YouTube chapters. It also drafts every platform's copy in one director-triggered provider call from their own making-of notes, and every field stays editable. Posting (#9282) fills each platform's post (YouTube, Suno, an X thread, Shorts, TikTok, Instagram Reels, Reddit, Stacker News) in a new PortOS Browser tab with the director's signed-in sessions, shows a screenshot and summary of the filled draft, and posts only when the director presses Post for that draft; the posted links are kept on the project. Platforms are opt-in (#9287): a "Where you post" list turns each one on (all start off) and optionally names the account posted as — X and Reddit drafts filled while signed in as someone else are refused. Copy is drafted and posts are offered only for enabled platforms. Each post (including one recorded by hand) can be rated good, mixed or poor with notes; ratings roll up per platform across projects and are passed to later copy drafts. | — |
| **Sharing & Conflict Resolution** | `/sharing`, `/sharing/duplicates`, `/sharing/conflicts` | Collaborative asset exchange via cloud storage buckets (Google Drive, Dropbox, iCloud, Syncthing) with duplicate reconciliation and conflict recovery journals. | — |
---
diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.js
index b398c90eea..214b916231 100644
--- a/server/lib/musicVideoValidation.js
+++ b/server/lib/musicVideoValidation.js
@@ -286,7 +286,8 @@ export const isDeterministicCodeSource = (source) => typeof source === 'string'
&& source.length > 0
&& source.length <= MUSIC_VIDEO_CODE_SOURCE_MAX
&& !MUSIC_VIDEO_CODE_NONDETERMINISTIC.test(source);
-export const MUSIC_VIDEO_TYPOGRAPHY_TEMPLATES = ['fade', 'rise', 'typewriter', 'pop'];
+// 'build' (#9291) lays a line down word by word on its sung onsets, the newest word in the accent color.
+export const MUSIC_VIDEO_TYPOGRAPHY_TEMPLATES = ['fade', 'rise', 'typewriter', 'pop', 'build'];
export const MUSIC_VIDEO_TYPOGRAPHY_PLACEMENTS = ['upper', 'center', 'lower'];
export const MUSIC_VIDEO_TYPOGRAPHY_EMPHASES = ['subtitle', 'hero'];
export const MUSIC_VIDEO_TYPOGRAPHY_FONTS = ['sans', 'serif', 'mono'];
@@ -299,6 +300,8 @@ export const musicVideoTextCueSchema = z.object({
template: z.enum(MUSIC_VIDEO_TYPOGRAPHY_TEMPLATES).optional(),
placement: z.enum(MUSIC_VIDEO_TYPOGRAPHY_PLACEMENTS).optional(),
emphasis: z.enum(MUSIC_VIDEO_TYPOGRAPHY_EMPHASES).optional(),
+ // Sung word onsets for the 'build' template (#9291).
+ words: z.array(z.object({ w: z.string().min(1).max(60), atSec: z.number().min(0).max(36000) }).strict()).max(80).optional(),
}).strict();
const codeSectionSource = z.string().min(1).max(MUSIC_VIDEO_CODE_SOURCE_MAX)
@@ -357,6 +360,7 @@ export const musicVideoCompositionSchema = z.object({
style: z.object({
color: z.string().regex(/^#[0-9a-f]{6}$/i, 'color is #rrggbb').optional(),
font: z.enum(MUSIC_VIDEO_TYPOGRAPHY_FONTS).optional(),
+ accentColor: z.string().regex(/^#[0-9a-f]{6}$/i, 'accentColor is #rrggbb').optional(),
}).strict().optional(),
posterSec: timedSec,
codeVideo: musicVideoCodeVideoSchema.nullable().optional(),
diff --git a/server/services/musicVideo/composition.js b/server/services/musicVideo/composition.js
index 55424743e5..db3266cda7 100644
--- a/server/services/musicVideo/composition.js
+++ b/server/services/musicVideo/composition.js
@@ -107,6 +107,17 @@ function normalizeCompositionOverlay(input) {
* keeps its text but loses its end (it does not render until re-timed). Returns
* null for a non-object so a cleared manifest stays cleared.
*/
+/** A cue's sung word onsets (#9291), in time order; null when there are none. */
+function cueWords(words) {
+ if (!Array.isArray(words)) return null;
+ const out = words
+ .filter((w) => w && typeof w.w === 'string' && w.w.trim() && toTime(w.atSec) != null)
+ .slice(0, 80)
+ .map((w) => ({ w: w.w.trim().slice(0, 60), atSec: toTime(w.atSec) }))
+ .sort((a, b) => a.atSec - b.atSec);
+ return out.length ? out : null;
+}
+
export function normalizeComposition(input) {
if (!input || typeof input !== 'object' || Array.isArray(input)) return null;
const seen = new Set();
@@ -126,6 +137,7 @@ export function normalizeComposition(input) {
template: pick(cue.template, TYPOGRAPHY_TEMPLATES, 'fade'),
placement: pick(cue.placement, TYPOGRAPHY_PLACEMENTS, 'lower'),
emphasis: pick(cue.emphasis, TYPOGRAPHY_EMPHASES, 'subtitle'),
+ ...(cueWords(cue.words) ? { words: cueWords(cue.words) } : {}),
});
}
const style = input.style && typeof input.style === 'object' ? input.style : {};
@@ -139,6 +151,7 @@ export function normalizeComposition(input) {
style: {
color: typeof style.color === 'string' && /^#[0-9a-f]{6}$/i.test(style.color) ? style.color.toLowerCase() : '#ffffff',
font: pick(style.font, TYPOGRAPHY_FONTS, 'sans'),
+ ...(typeof style.accentColor === 'string' && /^#[0-9a-f]{6}$/i.test(style.accentColor) ? { accentColor: style.accentColor.toLowerCase() } : {}),
},
posterSec: toTime(input.posterSec),
// Absent until chosen (#9290): the autopilot plan picks 'intercut' for an undecided project.
@@ -235,6 +248,20 @@ export function cueStateAt(cue, t) {
} else if (cue.template === 'pop') {
// Grows into place and never past full size, so it cannot leave the safe area.
scale = 0.85 + 0.15 * easeOut(inP);
+ } else if (cue.template === 'build') {
+ // #9291: each word lands on its sung onset (evenly over the first 60% of
+ // the cue when no onsets are known); the line holds, then fades out.
+ const words = Array.isArray(cue.words) && cue.words.length ? cue.words.map((w) => w.atSec) : null;
+ // Tokens counted inline: this function is serialized into the overlay
+ // page (cueStateAt.toString()), so it cannot import lib/textUtils.
+ let count = 0;
+ if (words) count = words.length;
+ else for (const token of String(cue.text).split(/\s+/)) if (token) count += 1;
+ let shown = 0;
+ if (words) for (const at of words) { if (at <= t + 1e-6) shown += 1; }
+ else shown = count ? Math.min(count, 1 + Math.floor(clamp((t - start) / (span * 0.6)) * count)) : 0;
+ opacity = easeOut(outP);
+ return { opacity: Math.round(opacity * 10000) / 10000, offsetY: 0, scale: 1, visibleChars: length, visibleWords: Math.max(1, shown) };
} else if (cue.template === 'typewriter') {
const typeSec = Math.min(span * 0.6, length * 0.05);
visibleChars = typeSec > 0 ? Math.min(length, Math.ceil(length * clamp((t - start) / typeSec))) : length;
@@ -277,9 +304,10 @@ const scriptJson = (value) => JSON.stringify(value).replace(/</g, '\\u003c');
* box never changes between frames and cannot leave the safe area.
*/
export function buildTypographyDocument({ cues, style = {}, width, height, durationSec, fps }) {
- const payload = cues.map(({ id, text, startSec, endSec, template, placement, emphasis }) => ({ id, text, startSec, endSec, template, placement, emphasis }));
+ const payload = cues.map(({ id, text, startSec, endSec, template, placement, emphasis, words }) => ({ id, text, startSec, endSec, template, placement, emphasis, ...(words ? { words } : {}) }));
const color = /^#[0-9a-f]{6}$/i.test(style.color || '') ? style.color : '#ffffff';
const fontStack = FONT_STACKS[style.font] || FONT_STACKS.sans;
+ const accent = /^#[0-9a-f]{6}$/i.test(style.accentColor || '') ? style.accentColor : '#ff5a1f';
return `<!doctype html><html><head><meta charset="utf-8"><style>
html, body { margin: 0; padding: 0; background: transparent; overflow: hidden; }
#safe { position: absolute; }
@@ -288,20 +316,35 @@ html, body { margin: 0; padding: 0; background: transparent; overflow: hidden; }
/* The padding keeps this legibility shadow inside the cue box, and so inside the safe area. */
text-shadow: 0 0 0.12em rgba(0,0,0,0.85), 0 0.04em 0.18em rgba(0,0,0,0.7); }
.cue .rest { visibility: hidden; }
+/* #9291 word build: heavy condensed caps, words hold their place as they land. */
+.cue.build { text-align: left; font-family: Impact, "Arial Narrow Bold", "Arial Narrow", ${fontStack}; font-weight: 900; text-transform: uppercase; letter-spacing: 0.01em; line-height: 0.98; }
+.cue.build .word { visibility: hidden; }
</style></head><body><div id="safe"></div><script>
const CUES = ${scriptJson(payload)};
const SAFE_INSET = ${SAFE_INSET};
+const ACCENT = ${scriptJson(accent)};
const cueStateAt = ${cueStateAt.toString()};
const safe = document.getElementById('safe');
const nodes = CUES.map((cue) => {
const el = document.createElement('div');
- el.className = 'cue';
+ el.className = cue.template === 'build' ? 'cue build' : 'cue';
const shown = document.createElement('span');
const rest = document.createElement('span');
rest.className = 'rest';
- el.append(shown, rest);
+ const words = [];
+ if (cue.template === 'build') {
+ const tokens = cue.words && cue.words.length ? cue.words.map((w) => w.w) : cue.text.split(/\s+/).filter(Boolean);
+ tokens.forEach((token, i) => {
+ const span = document.createElement('span');
+ span.className = 'word';
+ span.textContent = token;
+ if (i) el.append(' ');
+ el.append(span);
+ words.push(span);
+ });
+ } else el.append(shown, rest);
safe.append(el);
- return { cue, el, shown, rest, chars: Array.from(cue.text) };
+ return { cue, el, shown, rest, words, chars: Array.from(cue.text) };
});
let frame = { width: ${Number(width)}, height: ${Number(height)} };
function layout({ width, height }) {
@@ -314,10 +357,10 @@ function layout({ width, height }) {
const base = Math.min(width, height);
for (const node of nodes) {
const hero = node.cue.emphasis === 'hero';
- const maxH = safeH * (hero ? 0.6 : 0.3);
- node.shown.textContent = node.cue.text;
- node.rest.textContent = '';
- let size = Math.round(base * (hero ? 0.09 : 0.05));
+ const build = node.words.length > 0;
+ const maxH = safeH * (hero || build ? 0.6 : 0.3);
+ if (!build) { node.shown.textContent = node.cue.text; node.rest.textContent = ''; }
+ let size = Math.round(base * (build ? 0.13 : hero ? 0.09 : 0.05));
const floor = Math.max(8, Math.round(base * 0.02));
node.el.style.fontSize = size + 'px';
while (size > floor && (node.el.scrollHeight > maxH || node.el.scrollWidth > safeW)) {
@@ -338,7 +381,19 @@ function layout({ width, height }) {
function draw(t) {
for (const node of nodes) {
const state = cueStateAt(node.cue, t);
- if (!state) { node.el.style.visibility = 'hidden'; continue; }
+ // A word span set visible would show through its hidden cue, so hide both.
+ if (!state) { node.el.style.visibility = 'hidden'; node.words.forEach((span) => { span.style.visibility = 'hidden'; }); continue; }
+ if (node.words.length) {
+ const n = state.visibleWords || 0;
+ node.words.forEach((span, i) => {
+ span.style.visibility = i < n ? 'visible' : 'hidden';
+ span.style.color = i === n - 1 ? ACCENT : '';
+ });
+ node.el.style.visibility = 'visible';
+ node.el.style.opacity = String(state.opacity);
+ node.el.style.transform = 'none';
+ continue;
+ }
node.shown.textContent = node.chars.slice(0, state.visibleChars).join('');
node.rest.textContent = node.chars.slice(state.visibleChars).join('');
node.el.style.visibility = 'visible';
diff --git a/server/services/musicVideo/hookTypography.js b/server/services/musicVideo/hookTypography.js
new file mode 100644
index 0000000000..e2b29330b0
--- /dev/null
+++ b/server/services/musicVideo/hookTypography.js
@@ -0,0 +1,31 @@
+/**
+ * Music Video — hook typography (#9291).
+ *
+ * The reference analysis (#9289) found hooks carried by type: a repeated line
+ * lands word by word on the sung onsets, big and centered, the newest word in
+ * the accent color. A lyric line sung two or more times is a hook; its text
+ * cue takes the `build` template with its words' onsets.
+ */
+
+const isTime = (n) => typeof n === 'number' && Number.isFinite(n) && n >= 0;
+
+/** A line's identity for repeat counting: lowercase letters/digits, single spaces. */
+export const hookKey = (text) => String(text || '').toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, '').replace(/\s+/g, ' ').trim();
+
+/** The keys of every lyric line sung two or more times. */
+export function hookLines(cues) {
+ const counts = new Map();
+ for (const cue of Array.isArray(cues) ? cues : []) {
+ const k = hookKey(cue?.text);
+ if (k) counts.set(k, (counts.get(k) || 0) + 1);
+ }
+ return new Set([...counts].filter(([, n]) => n >= 2).map(([k]) => k));
+}
+
+/** A lyric cue's aligned word onsets inside [its start, endSec), as `{ w, atSec }` (at most 80). */
+export function cueWordOnsets(cue, endSec) {
+ return (Array.isArray(cue?.words) ? cue.words : [])
+ .filter((w) => w && typeof w.w === 'string' && w.w.trim() && isTime(w.startSec) && w.startSec >= cue.startSec - 0.05 && w.startSec < endSec)
+ .slice(0, 80)
+ .map((w) => ({ w: w.w.trim().slice(0, 60), atSec: w.startSec }));
+}
diff --git a/server/services/musicVideo/hookTypography.test.js b/server/services/musicVideo/hookTypography.test.js
new file mode 100644
index 0000000000..1ae3d2dbbf
--- /dev/null
+++ b/server/services/musicVideo/hookTypography.test.js
@@ -0,0 +1,41 @@
+/**
+ * Hook typography (#9291): repeated lines are hooks, and a hook cue carries
+ * its sung word onsets for the word-by-word build.
+ */
+import { describe, expect, it } from 'vitest';
+import { cueWordOnsets, hookKey, hookLines } from './hookTypography.js';
+import { buildTypographyDocument, cueStateAt, normalizeComposition } from './composition.js';
+
+describe('hook typography (#9291)', () => {
+ it('finds lines sung two or more times, ignoring case and punctuation', () => {
+ const hooks = hookLines([{ text: 'Tie me to the mast!' }, { text: 'tie me to the MAST' }, { text: 'Once only' }]);
+ expect([...hooks]).toEqual([hookKey('Tie me to the mast')]);
+ });
+
+ it('keeps the cue\'s aligned word onsets inside its span', () => {
+ const cue = { startSec: 10, words: [{ w: 'Tie', startSec: 10.02 }, { w: 'me', startSec: 10.4 }, { w: ' ', startSec: 10.5 }, { w: 'late', startSec: 13 }, { w: 'x', startSec: null }] };
+ expect(cueWordOnsets(cue, 12)).toEqual([{ w: 'Tie', atSec: 10.02 }, { w: 'me', atSec: 10.4 }]);
+ });
+
+ it('builds word by word on the onsets and fades the held line out', () => {
+ const cue = { id: 'h', text: 'Tie me to the mast', startSec: 10, endSec: 14, template: 'build', placement: 'center', emphasis: 'hero',
+ words: [{ w: 'Tie', atSec: 10 }, { w: 'me', atSec: 10.5 }, { w: 'to', atSec: 11 }, { w: 'the', atSec: 11.2 }, { w: 'mast', atSec: 11.6 }] };
+ expect(cueStateAt(cue, 10.1)).toMatchObject({ visibleWords: 1, opacity: 1 });
+ expect(cueStateAt(cue, 11.1)).toMatchObject({ visibleWords: 3 });
+ expect(cueStateAt(cue, 12)).toMatchObject({ visibleWords: 5, opacity: 1 });
+ expect(cueStateAt(cue, 13.9).opacity).toBeLessThan(1);
+ // Without onsets the words spread over the first 60% of the cue.
+ expect(cueStateAt({ ...cue, words: undefined }, 10).visibleWords).toBe(1);
+ expect(cueStateAt({ ...cue, words: undefined }, 12.5).visibleWords).toBe(5);
+ });
+
+ it('keeps words and the accent color through normalization and into the overlay page', () => {
+ const comp = normalizeComposition({ mode: 'composed', style: { accentColor: '#FF0000' }, textCues: [{ text: 'Tie me', startSec: 1, endSec: 3, template: 'build', words: [{ w: 'me', atSec: 1.5 }, { w: 'Tie', atSec: 1 }] }] });
+ expect(comp.style.accentColor).toBe('#ff0000');
+ expect(comp.textCues[0].words).toEqual([{ w: 'Tie', atSec: 1 }, { w: 'me', atSec: 1.5 }]);
+ expect(normalizeComposition({ textCues: [] }).style).toEqual({ color: '#ffffff', font: 'sans' });
+ const html = buildTypographyDocument({ cues: comp.textCues, style: comp.style, width: 1920, height: 1080, durationSec: 5, fps: 24 });
+ expect(html).toContain('const ACCENT = "#ff0000"');
+ expect(html).toContain('"words":[{"w":"Tie","atSec":1}');
+ });
+});
diff --git a/server/services/musicVideo/treatment.js b/server/services/musicVideo/treatment.js
index 68c248322c..6439e91a04 100644
--- a/server/services/musicVideo/treatment.js
+++ b/server/services/musicVideo/treatment.js
@@ -56,6 +56,7 @@ import {
} from '../../lib/musicVideoValidation.js';
import { performanceCapability } from '../../lib/musicVideoShotTiming.js';
import { normalizeComposition } from './composition.js';
+import { hookKey, hookLines, cueWordOnsets } from './hookTypography.js';
const TREATMENT_VERSION = 1;
@@ -591,6 +592,7 @@ const withPlannedScenes = (project, planned) => {
function textCueCandidates(project, treatment) {
const scenes = new Map((project.scenes || []).map((s) => [s.sceneId, s]));
const cues = (project.lyricCues || []).filter((c) => isNonBlankStr(c?.text) && isTime(c.startSec));
+ const hooks = hookLines(cues);
const existing = new Set((project.composition?.textCues || []).map((c) => `${c.text}@${c.startSec}`));
const out = [];
for (const direction of treatment.shotDirections) {
@@ -607,7 +609,11 @@ function textCueCandidates(project, treatment) {
// Clamped to the directing shot: a line that runs on must not keep its
// text over a later shot that reserved no (or another) region for it.
const endSec = isTime(cue.endSec) && cue.endSec > cue.startSec ? Math.min(cue.endSec, scene.endSec) : scene.endSec;
- out.push({
+ const words = hooks.has(hookKey(cueText)) ? cueWordOnsets(cue, endSec) : [];
+ out.push(words.length ? {
+ // A hook builds word by word, big and centered (#9291).
+ text: cueText, startSec: cue.startSec, endSec, placement: 'center', emphasis: 'hero', template: 'build', words,
+ } : {
text: cueText,
startSec: cue.startSec,
endSec,