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

Opening title card: Storyboard panel, classic MTV look, composed renders (#11199)

[._.]/23e66f8294d0
diff --git a/client/src/components/musicVideo/TitleCardPanel.jsx b/client/src/components/musicVideo/TitleCardPanel.jsx
index 23753b807c..d3df5997c8 100644
--- a/client/src/components/musicVideo/TitleCardPanel.jsx
+++ b/client/src/components/musicVideo/TitleCardPanel.jsx
@@ -2,11 +2,14 @@ import { useState } from 'react';
import { Clapperboard, Play } from 'lucide-react';
import { getMusicVideoPublishPlatforms } from '../../services/apiMusicVideo.js';
import {
- TITLE_CARD_LIMITS, normalizeTitleCard, titleCardPrefill,
+ TITLE_CARD_LIMITS, TITLE_CARD_MTV_COLORS, normalizeTitleCard, titleCardPrefill,
} from '../../../../server/lib/musicVideoTitleCard.js';
const POSITIONS = [['lower-left', 'Bottom left'], ['lower-right', 'Bottom right'], ['upper-left', 'Top left'], ['upper-right', 'Top right'], ['lower-center', 'Bottom centre'], ['center', 'Centre']];
const FONTS = [['display', 'Lyric type'], ['sans', 'Helvetica'], ['serif', 'Serif'], ['mono', 'Mono']];
+const LOOKS = [['outline', 'Outlined, like the lyrics'], ['mtv', 'Classic MTV lower third']];
+// Render styles that draw the card: the composition document and a composed cut's typography layer.
+const DRAWN_BY = ['document', 'composed'];
const inputCls = 'w-full rounded border border-port-border bg-port-bg px-2 py-1 text-sm min-h-[44px] sm:min-h-0';
const labelCls = 'mb-0.5 block text-xs text-port-text-muted';
const clock = (sec) => {
@@ -24,15 +27,17 @@ function lyricDuringCard(project, card) {
/**
* The MTV-style opening title card (lib/musicVideoTitleCard.js): song title,
- * artist and year in a corner, fading in and out over the opener. Drawn over
- * the composition document in the docked live preview and the final render.
+ * artist and year in a corner, fading in and out over the opener, outlined like
+ * the lyrics or as a classic lower third. Drawn in the docked live preview, the
+ * storyboard animatic and the final render (composed or document styles).
* Turning it on fills the song title, the artist named for DistroKid under
* Where you post, this year and a window that ends before the first sung line.
* Edits reach the preview at once (`onEditLocal`); leaving a field saves.
+ * `bare` drops the panel's own heading where a section around it carries one.
*/
-export default function TitleCardPanel({ project, onEditLocal, onSave, onPreview }) {
+export default function TitleCardPanel({ project, onEditLocal, onSave, onPreview, bare = false }) {
const [starting, setStarting] = useState(false);
- const documentMode = project.composition?.mode === 'document';
+ const drawn = DRAWN_BY.includes(project.composition?.mode);
const raw = project.titleCard || null;
const card = normalizeTitleCard(raw);
const on = !!card?.enabled;
@@ -65,17 +70,17 @@ export default function TitleCardPanel({ project, onEditLocal, onSave, onPreview
const field = (key) => (raw?.[key] ?? card?.[key] ?? '');
return (
- <section aria-label="Opening title card" className="space-y-2 border-t border-port-border pt-3">
+ <section aria-label="Opening title card" className={bare ? 'space-y-2' : 'space-y-2 border-t border-port-border pt-3'}>
<div className="flex flex-wrap items-center justify-between gap-2">
- <h3 className="inline-flex items-center gap-1.5 text-sm font-medium"><Clapperboard size={14} className="text-port-accent" aria-hidden="true" /> Opening title card</h3>
+ {!bare && <h3 className="inline-flex items-center gap-1.5 text-sm font-medium"><Clapperboard size={14} className="text-port-accent" aria-hidden="true" /> Opening title card</h3>}
<label htmlFor="mv-title-card-on" className="inline-flex min-h-[44px] items-center gap-2 text-xs text-port-text-muted sm:min-h-0">
{on ? `Live in the preview · ${clock(card.startSec)}–${clock(card.endSec)}` : 'Off'}
<input id="mv-title-card-on" type="checkbox" checked={on} disabled={starting}
onChange={(e) => (e.target.checked ? turnOn() : commit({ enabled: false }))} className="h-4 w-4" />
</label>
</div>
- {!documentMode && on && (
- <p className="text-xs text-port-text-muted" role="status">The title card is drawn by the composition-document render style; this project's render style ignores it.</p>
+ {!drawn && on && (
+ <p className="text-xs text-port-text-muted" role="status">This project's render style does not draw the title card; the composed and composition-document styles do.</p>
)}
{on && (
<>
@@ -118,6 +123,12 @@ export default function TitleCardPanel({ project, onEditLocal, onSave, onPreview
onChange={(e) => edit({ fadeSec: toNumber(e.target.value) })} onBlur={() => commit()} className={inputCls} />
</div>
</div>
+ <div>
+ <label htmlFor="mv-title-card-look" className={labelCls}>Look</label>
+ <select id="mv-title-card-look" value={card.style} onChange={(e) => commit({ style: e.target.value })} className={inputCls}>
+ {LOOKS.map(([value, label]) => <option key={value} value={value}>{label}</option>)}
+ </select>
+ </div>
<div className="grid grid-cols-2 gap-2">
<div>
<label htmlFor="mv-title-card-position" className={labelCls}>Position</label>
@@ -140,10 +151,22 @@ export default function TitleCardPanel({ project, onEditLocal, onSave, onPreview
className="h-11 w-full sm:h-auto" />
</div>
<div>
- <label htmlFor="mv-title-card-color" className={labelCls}>Color</label>
+ <label htmlFor="mv-title-card-color" className={labelCls}>Text</label>
<input id="mv-title-card-color" type="color" value={card.color}
onChange={(e) => edit({ color: e.target.value })} onBlur={() => commit()} className="h-11 w-14 rounded border border-port-border bg-port-bg sm:h-8" />
</div>
+ <div>
+ <label htmlFor="mv-title-card-title-color" className={labelCls}>Title</label>
+ <input id="mv-title-card-title-color" type="color" value={card.titleColor || (card.style === 'mtv' ? TITLE_CARD_MTV_COLORS.title : card.color)}
+ onChange={(e) => edit({ titleColor: e.target.value })} onBlur={() => commit()} className="h-11 w-14 rounded border border-port-border bg-port-bg sm:h-8" />
+ </div>
+ {card.style === 'mtv' && (
+ <div>
+ <label htmlFor="mv-title-card-accent" className={labelCls}>Bar</label>
+ <input id="mv-title-card-accent" type="color" value={card.accentColor || TITLE_CARD_MTV_COLORS.accent}
+ onChange={(e) => edit({ accentColor: e.target.value })} onBlur={() => commit()} className="h-11 w-14 rounded border border-port-border bg-port-bg sm:h-8" />
+ </div>
+ )}
<label htmlFor="mv-title-card-quote" className="inline-flex min-h-[44px] items-center gap-2 text-xs text-port-text-muted sm:min-h-0">
<input id="mv-title-card-quote" type="checkbox" checked={card.quoteTitle} onChange={(e) => commit({ quoteTitle: e.target.checked })} className="h-4 w-4" />
Quote the title
diff --git a/client/src/components/musicVideo/TitleCardPanel.test.jsx b/client/src/components/musicVideo/TitleCardPanel.test.jsx
index 9a626ec662..06f2c81aaa 100644
--- a/client/src/components/musicVideo/TitleCardPanel.test.jsx
+++ b/client/src/components/musicVideo/TitleCardPanel.test.jsx
@@ -64,4 +64,13 @@ describe('TitleCardPanel', () => {
expect(onSave).toHaveBeenLastCalledWith({ titleCard: expect.objectContaining({ enabled: false, title: 'Example Song', year: '1984' }) });
expect(screen.queryByLabelText('Song title')).toBeNull();
});
+
+ it('switches to the classic MTV lower third and offers its bar colour', () => {
+ const onSave = vi.fn().mockResolvedValue({});
+ render(<Harness initial={{ ...base, titleCard: { enabled: true, title: 'Example Song', startSec: 1, endSec: 5 } }} onSave={onSave} />);
+ expect(screen.queryByLabelText('Bar')).toBeNull();
+ fireEvent.change(screen.getByLabelText('Look'), { target: { value: 'mtv' } });
+ expect(onSave).toHaveBeenLastCalledWith({ titleCard: expect.objectContaining({ style: 'mtv', title: 'Example Song' }) });
+ expect(screen.getByLabelText('Bar')).toBeInTheDocument();
+ });
});
diff --git a/client/src/components/musicVideo/stages/BoardStage.jsx b/client/src/components/musicVideo/stages/BoardStage.jsx
index d676682895..2100ecbef1 100644
--- a/client/src/components/musicVideo/stages/BoardStage.jsx
+++ b/client/src/components/musicVideo/stages/BoardStage.jsx
@@ -8,6 +8,8 @@ import TreatmentPanel, { treatmentSummary } from '../TreatmentPanel.jsx';
import StageSection from '../StageSection.jsx';
import { PlanActions } from '../ProjectActionGroups.jsx';
import ShotPacingFields from '../ShotPacingFields.jsx';
+import TitleCardPanel from '../TitleCardPanel.jsx';
+import { normalizeTitleCard } from '../../../../../server/lib/musicVideoTitleCard.js';
import { isLayeredComposition } from '../../../lib/musicVideoLayers.js';
import { FOOTAGE_OPTIONAL_MODES } from '../../../lib/musicVideoStages.js';
import { parseSceneFilter, sceneAttention, sceneMatchesFilter, SCENE_ATTENTION_LABELS } from '../../../lib/musicVideoSceneAttention.js';
@@ -17,9 +19,17 @@ import { formatTimecode } from '../../../utils/formatters.js';
const FILTER_LABELS = [['all', 'All'], ['attention', 'Needs attention'], ['missing', 'Missing footage']];
const isTypingTarget = (el) => !!el && (el.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(el.tagName));
+/** One line for the folded title card section: off, or what it says and when. */
+function titleCardSummary(stored) {
+ const card = normalizeTitleCard(stored);
+ if (!card?.enabled) return 'Off · the song, artist and year over the opener';
+ const words = [card.title && `“${card.title}”`, card.artist].filter(Boolean).join(' · ') || 'No text yet';
+ return `${words} · ${formatTimecode(card.startSec, 1)}–${formatTimecode(card.endSec, 1)}`;
+}
+
/**
* Storyboard: the treatment (the brief the planner reads, then per-shot
- * direction), planning tools, the beat timeline, and the scene cards —
+ * direction), planning tools, the opening title card, the beat timeline, and the scene cards —
* one column on a phone, two and three as the column widens (a container
* query, so the docked preview narrowing the column is accounted for). Cards
* are collapsed to a thumbnail, lyric and status until tapped.
@@ -102,6 +112,12 @@ export default function BoardStage({ board }) {
<ShotPacingFields project={project} onEditLocal={board.editProjectLocal} onSave={board.saveProjectFields} />
</StageSection>
+ {/* The opening credit block, set here so it plays in the storyboard animatic from the start. */}
+ <StageSection id="mv-board-title-card" title="Opening title card" summary={titleCardSummary(project.titleCard)}>
+ <TitleCardPanel bare project={project} onEditLocal={board.editProjectLocal} onSave={board.saveProjectFields}
+ onPreview={board.seekToScene ? (startSec) => board.seekToScene({ startSec }, { play: true }) : null} />
+ </StageSection>
+
{/* The brief feeds the shot planner; the direction is applied per shot once they exist. */}
<StageSection id="mv-board-treatment" title="Treatment" summary={scenes.length ? treatmentSummary(project) : 'Write the brief the shot planner follows'}>
<div id="mv-setup-treatment">
diff --git a/docs/HTML_COMPOSITIONS.md b/docs/HTML_COMPOSITIONS.md
index 3d7042c900..fb5f0172d9 100644
--- a/docs/HTML_COMPOSITIONS.md
+++ b/docs/HTML_COMPOSITIONS.md
@@ -324,15 +324,15 @@ projects; the composed render style keeps its own render grade above.
The MTV-style credit block a video opens with: song title, artist, year and an
optional extra line (album, director), fading in over the opener and out again.
-**Compose → Opening title card** stores it on the project (`project.titleCard`,
+**Storyboard → Opening title card** (also under **Compose**) stores it on the project (`project.titleCard`,
validated by `musicVideoTitleCardSchema`, normalized by `normalizeTitleCard` in
`server/lib/musicVideoTitleCard.js`; `null` = none, `enabled: false` keeps the
text). Turning it on fills the song title (the project name without its version
suffix), the artist named for DistroKid under Where you post, this year, and a
window that ends half a second before the first sung line. Timing (in, out,
fade), position (four corners, bottom centre, centre), font (the lyric type's
-Archivo, Helvetica, serif, Plex Mono), size and color are all editable; the
-panel flags a sung line that starts while the card is up and offers to end the
+Archivo, Helvetica, serif, Plex Mono), size, look and colors are all editable;
+the panel flags a sung line that starts while the card is up and offers to end the
card before it.
The card is not part of the composition document. `titleCardRuntimeSource()`
@@ -341,12 +341,18 @@ arrive as `portos-mv:title-card` messages) and in every render browser
(`documentRenderInitScripts`). It draws on its own canvas fixed over the page,
fitted to the render's aspect, and wraps `portosComposition.seek()` (chaining
the film look's wrapper) so the card is drawn for each frame after its faces
-load. It follows the lyric type: cream fill, ink outline, no plate, inside the
-same title-safe insets, and a block wider than its zone shrinks rather than
-running off frame. Like the lyrics it sits under the film look. It also rides
+load. It has two looks (`style`). `outline` follows the lyric type: cream fill, ink
+outline, no plate. `mtv` is the classic lower third: the artist in bold caps
+over the title, on a dark translucent plate with a colored bar on its leading
+edge (`accentColor`, cyan by default) and the title in `titleColor` (yellow by
+default). Both sit inside the same title-safe insets, and a block wider than
+its zone shrinks rather than running off frame. Like the lyrics it sits under the film look. It also rides
on the lyric pages (the lyric-timing playthrough and the lyrics laid over the
storyboard animatic, which carry no film look), so it can be checked against
-the timed words before the composition exists.
+the timed words before the composition exists. A composed render (`composition.mode:
+'composed'`) and its draft excerpts draw it too: `projectTypographyPlan` adds a
+text-less `title-card` cue, and `buildTypographyDocument` installs the same
+runtime on the transparent overlay page captured over the cut.
## Music-video composition documents
diff --git a/server/lib/musicVideoTitleCard.browser.test.js b/server/lib/musicVideoTitleCard.browser.test.js
index cca0e99440..1ad296130d 100644
--- a/server/lib/musicVideoTitleCard.browser.test.js
+++ b/server/lib/musicVideoTitleCard.browser.test.js
@@ -88,6 +88,29 @@ describe.skipIf(!canRun)('title card runtime in Chrome', () => {
expect(long).toBeLessThanOrEqual(W * 0.62 + 0.5);
}, 30000);
+ it('draws the classic MTV lower third: artist in caps over a yellow title, on a dark plate with a coloured bar', async () => {
+ await page.evaluate(() => globalThis.__portosTitleCard.apply({ ...globalThis.__portosTitleCard.card, style: 'mtv', position: 'lower-left', titleColor: '', accentColor: '#00ff00' }));
+ const lines = await page.evaluate(() => globalThis.__portosTitleCard.layout());
+ expect(lines.map((l) => l.text)).toEqual(['EXAMPLE ARTIST', '“Example Song”', '2026']);
+ expect(lines[1].fill).toBe('#f5d33a');
+ expect(lines.every((l) => l.outline === 0)).toBe(true);
+ const shot = await shotAt(5);
+ const { data, info } = await sharp(shot).raw().toBuffer({ resolveWithObject: true });
+ let bar = 0;
+ let yellow = 0;
+ for (let i = 0; i < data.length; i += info.channels) {
+ const [r, g, b] = [data[i], data[i + 1], data[i + 2]];
+ if (g > 200 && r < 60 && b < 60) bar += 1;
+ if (r > 200 && g > 170 && b < 110) yellow += 1;
+ }
+ expect(bar).toBeGreaterThan(100);
+ expect(yellow).toBeGreaterThan(50);
+ // The plate stays inside the frame and in the lower-left quarter.
+ expect(await brightIn(shot, upperRight)).toBe(0);
+ await page.evaluate(() => globalThis.__portosTitleCard.apply({ ...globalThis.__portosTitleCard.card, style: 'outline' }));
+ expect(errors).toEqual([]);
+ }, 30000);
+
it('takes a live change from the panel and redraws the paused frame, and clears on null', async () => {
await shotAt(5);
await page.evaluate(() => globalThis.__portosTitleCard.apply({ ...globalThis.__portosTitleCard.card, position: 'upper-right' }));
diff --git a/server/lib/musicVideoTitleCard.js b/server/lib/musicVideoTitleCard.js
index 43af96c09d..2fbb75963a 100644
--- a/server/lib/musicVideoTitleCard.js
+++ b/server/lib/musicVideoTitleCard.js
@@ -8,21 +8,29 @@
* versions the director may have authored); `titleCardRuntimeSource()` is a
* page script installed beside the document — in the preview's head and in
* every render browser (`documentRenderInitScripts`) — that draws the card on
- * its own canvas above the page, re-drawn for every seek. It follows the
- * shared lyric type (lyricType.js): cream fill with an ink outline, no plate,
- * inside the same title-safe insets, so it reads like the lyrics.
+ * its own canvas above the page, re-drawn for every seek. Two looks:
+ * - `outline` follows the shared lyric type (lyricType.js): cream fill with
+ * an ink outline, no plate, title first, so it reads like the lyrics;
+ * - `mtv` is the classic 80s lower third: artist in caps over the quoted
+ * title in its own colour, then the extra line and year, on a dark plate
+ * with a coloured bar down its leading edge.
+ * Both sit inside the same title-safe insets and shrink to fit the frame.
*
* Every frame is a pure function of song time. Browser-safe, no imports.
*/
export const TITLE_CARD_POSITIONS = Object.freeze(['lower-left', 'lower-right', 'upper-left', 'upper-right', 'lower-center', 'center']);
export const TITLE_CARD_FONTS = Object.freeze(['display', 'sans', 'serif', 'mono']);
+export const TITLE_CARD_STYLES = Object.freeze(['outline', 'mtv']);
+/** The `mtv` look's title and bar colours when the card names none. */
+export const TITLE_CARD_MTV_COLORS = Object.freeze({ title: '#f5d33a', accent: '#1fc2e5' });
export const TITLE_CARD_LIMITS = Object.freeze({
textMax: 120, yearMax: 20, startMax: 600, windowMin: 0.5, fadeMax: 3, sizeMin: 50, sizeMax: 200,
});
export const TITLE_CARD_DEFAULTS = Object.freeze({
enabled: true, title: '', artist: '', year: '', extra: '', quoteTitle: true,
startSec: 2, endSec: 8, fadeSec: 0.8, position: 'lower-left', font: 'display', size: 100, color: '#f3ead7',
+ style: 'outline', titleColor: '', accentColor: '',
});
const clampNum = (value, min, max, fallback) => {
@@ -31,6 +39,7 @@ const clampNum = (value, min, max, fallback) => {
};
const cleanText = (value, max) => (typeof value === 'string' ? value.replace(/\s+/g, ' ').trim().slice(0, max) : '');
const round3 = (n) => Math.round(n * 1000) / 1000;
+const hexOr = (value, fallback) => (typeof value === 'string' && /^#[0-9a-f]{6}$/i.test(value) ? value.toLowerCase() : fallback);
/**
* A stored title card from any input (null for none). Missing fields take
@@ -55,7 +64,11 @@ export function normalizeTitleCard(input) {
position: TITLE_CARD_POSITIONS.includes(input.position) ? input.position : D.position,
font: TITLE_CARD_FONTS.includes(input.font) ? input.font : D.font,
size: Math.round(clampNum(input.size, L.sizeMin, L.sizeMax, D.size)),
- color: typeof input.color === 'string' && /^#[0-9a-f]{6}$/i.test(input.color) ? input.color.toLowerCase() : D.color,
+ color: hexOr(input.color, D.color),
+ style: TITLE_CARD_STYLES.includes(input.style) ? input.style : D.style,
+ // '' = the look's own colour (the text colour, or the mtv yellow title / cyan bar).
+ titleColor: hexOr(input.titleColor, ''),
+ accentColor: hexOr(input.accentColor, ''),
};
}
@@ -97,10 +110,12 @@ function titleCardAlpha(card, t) {
/**
* The card's lines placed on a width × height frame: `[{ text, font, px, x, y,
- * align, outline }]` (y is the alphabetic baseline). The title is the first,
- * larger line; artist, year and the extra line follow. A block wider than its
- * zone shrinks as a whole, so the card never runs off frame. `measure(text,
- * font)` returns a width in pixels. Pure.
+ * align, outline, fill }]` (y is the alphabetic baseline). In the `outline`
+ * look the title is the first, larger line and artist, year and the extra line
+ * follow; in the `mtv` look the artist leads in caps, then the title, the extra
+ * line and the year, and the block is inset by its plate's padding. A block
+ * wider than its zone shrinks as a whole, so the card never runs off frame.
+ * `measure(text, font)` returns a width in pixels. Pure.
*/
function titleCardLayout(card, { width, height, measure }) {
const stacks = {
@@ -111,10 +126,14 @@ function titleCardLayout(card, { width, height, measure }) {
};
const [family, titleWeight, metaWeight] = stacks[card.font] || stacks.display;
const clean = (s) => String(s || '').replace(/\s+/g, ' ').trim();
+ const mtv = card.style === 'mtv';
+ const color = card.color || '#f3ead7';
+ const titleFill = card.titleColor || (mtv ? '#f5d33a' : color);
const title = clean(card.title);
- const rows = [];
- if (title) rows.push({ text: card.quoteTitle ? `“${title}”` : title, title: true });
- for (const key of ['artist', 'year', 'extra']) if (clean(card[key])) rows.push({ text: clean(card[key]), title: false });
+ const titleRow = title ? { text: card.quoteTitle ? `“${title}”` : title, role: 'title' } : null;
+ const meta = (key) => (clean(card[key]) ? { text: clean(card[key]), role: 'meta' } : null);
+ const artist = clean(card.artist) ? { text: mtv ? clean(card.artist).toUpperCase() : clean(card.artist), role: mtv ? 'lead' : 'meta' } : null;
+ const rows = (mtv ? [artist, titleRow, meta('extra'), meta('year')] : [titleRow, artist, meta('year'), meta('extra')]).filter(Boolean);
if (!rows.length) return [];
const unit = Math.min(width, height) / 1080;
const scale = (Number(card.size) || 100) / 100;
@@ -123,26 +142,33 @@ function titleCardLayout(card, { width, height, measure }) {
const position = card.position || 'lower-left';
const centered = position === 'center' || position === 'lower-center';
const portrait = height > width;
- const maxW = centered || portrait ? width - 2 * insetX : width * 0.62;
- const fontOf = (row, px) => `${row.title ? titleWeight : metaWeight} ${Math.floor(px * 100) / 100}px ${family}`;
- const baseOf = (row) => (row.title ? 50 : 36) * unit * scale;
+ // The mtv plate's padding (and its bar) sit inside the safe insets too.
+ const base = { title: mtv ? 42 : 50, lead: 46, meta: mtv ? 32 : 36 };
+ const padX = mtv ? 26 * unit * scale : 0;
+ const padY = mtv ? 16 * unit * scale : 0;
+ const bar = mtv ? 9 * unit * scale : 0;
+ const maxW = (centered || portrait ? width - 2 * insetX : width * 0.62) - 2 * padX - bar;
+ const weightOf = (row) => (row.role === 'meta' ? metaWeight : titleWeight);
+ const fontOf = (row, px) => `${weightOf(row)} ${Math.floor(px * 100) / 100}px ${family}`;
+ const baseOf = (row) => base[row.role] * unit * scale;
const widest = Math.max(...rows.map((row) => measure(row.text, fontOf(row, baseOf(row)))));
const fit = widest > maxW && widest > 0 ? maxW / widest : 1;
const sized = rows.map((row) => ({ ...row, px: baseOf(row) * fit }));
- const lineH = (row) => row.px * (row.title ? 1.18 : 1.3);
+ const lineH = (row) => row.px * (row.role === 'meta' ? 1.3 : 1.18);
const blockH = sized.reduce((sum, row) => sum + lineH(row), 0);
let top;
if (position === 'center') top = (height - blockH) / 2;
- else if (position.startsWith('upper')) top = insetY;
- else top = height - insetY - blockH;
+ else if (position.startsWith('upper')) top = insetY + padY;
+ else top = height - insetY - padY - blockH;
const align = centered ? 'center' : position.endsWith('right') ? 'right' : 'left';
- const x = align === 'left' ? insetX : align === 'right' ? width - insetX : width / 2;
+ const x = align === 'left' ? insetX + bar + padX : align === 'right' ? width - insetX - padX : width / 2;
const out = [];
let y = top;
for (const row of sized) {
y += lineH(row);
// The baseline sits a little above the line box's foot, leaving room for descenders.
- out.push({ text: row.text, font: fontOf(row, row.px), px: row.px, x, y: y - row.px * (row.title ? 0.24 : 0.3), align, outline: Math.max(2, row.px * (row.title ? 0.15 : 0.12)) });
+ out.push({ text: row.text, font: fontOf(row, row.px), px: row.px, x, y: y - row.px * (row.role === 'meta' ? 0.3 : 0.24), align,
+ outline: mtv ? 0 : Math.max(2, row.px * (row.role === 'meta' ? 0.12 : 0.15)), fill: row.role === 'title' ? titleFill : color });
}
return out;
}
@@ -159,13 +185,37 @@ function drawTitleCard(ctx, card, t, { width, height }) {
ctx.textBaseline = 'alphabetic';
ctx.lineJoin = 'round';
ctx.miterLimit = 2;
+ if (card.style === 'mtv') {
+ // The lower third's plate hugs the block; its bar runs down the leading edge.
+ const unit = Math.min(width, height) / 1080;
+ const scale = (Number(card.size) || 100) / 100;
+ const padX = 26 * unit * scale;
+ const padY = 16 * unit * scale;
+ const bar = 9 * unit * scale;
+ let left = Infinity; let right = -Infinity;
+ for (const line of lines) {
+ const w = measure(line.text, line.font);
+ const x0 = line.align === 'left' ? line.x : line.align === 'right' ? line.x - w : line.x - w / 2;
+ left = Math.min(left, x0); right = Math.max(right, x0 + w);
+ }
+ const top = lines[0].y - lines[0].px * 0.94 - padY;
+ const bottom = lines[lines.length - 1].y + lines[lines.length - 1].px * 0.3 + padY;
+ const plateLeft = left - padX - (lines[0].align === 'right' ? 0 : bar);
+ const plateRight = right + padX + (lines[0].align === 'right' ? bar : 0);
+ ctx.fillStyle = 'rgba(12, 12, 18, 0.74)';
+ ctx.fillRect(plateLeft, top, plateRight - plateLeft, bottom - top);
+ ctx.fillStyle = card.accentColor || '#1fc2e5';
+ ctx.fillRect(lines[0].align === 'right' ? plateRight - bar : plateLeft, top, bar, bottom - top);
+ }
for (const line of lines) {
ctx.font = line.font;
ctx.textAlign = line.align;
- ctx.lineWidth = line.outline;
- ctx.strokeStyle = '#141217';
- ctx.strokeText(line.text, line.x, line.y);
- ctx.fillStyle = card.color || '#f3ead7';
+ if (line.outline > 0) {
+ ctx.lineWidth = line.outline;
+ ctx.strokeStyle = '#141217';
+ ctx.strokeText(line.text, line.x, line.y);
+ }
+ ctx.fillStyle = line.fill || card.color || '#f3ead7';
ctx.fillText(line.text, line.x, line.y);
}
ctx.restore();
diff --git a/server/lib/musicVideoTitleCard.test.js b/server/lib/musicVideoTitleCard.test.js
index 0338399469..099036fbbd 100644
--- a/server/lib/musicVideoTitleCard.test.js
+++ b/server/lib/musicVideoTitleCard.test.js
@@ -9,6 +9,11 @@ describe('normalizeTitleCard', () => {
expect(card).toMatchObject({ title: 'Example Song Title', startSec: 5, endSec: 5.5, fadeSec: 3, size: 200, position: 'lower-left', font: 'display', color: '#abcdef' });
});
+ it('keeps a known look and its colours, and drops unknown ones to the look\'s own', () => {
+ expect(normalizeTitleCard({ style: 'mtv', titleColor: '#F5D33A', accentColor: '#1fc2e5' })).toMatchObject({ style: 'mtv', titleColor: '#f5d33a', accentColor: '#1fc2e5' });
+ expect(normalizeTitleCard({ style: 'neon', titleColor: 'yellow', accentColor: 3 })).toMatchObject({ style: 'outline', titleColor: '', accentColor: '' });
+ });
+
it('counts a card as visible only when enabled with some text', () => {
expect(titleCardVisible(normalizeTitleCard({ title: 'Song' }))).toBe(true);
expect(titleCardVisible(normalizeTitleCard({ title: 'Song', enabled: false }))).toBe(false);
diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.js
index ce017df506..f12f59c13a 100644
--- a/server/lib/musicVideoValidation.js
+++ b/server/lib/musicVideoValidation.js
@@ -1,7 +1,7 @@
import { MUSIC_VIDEO_MEDIA_MODES } from './musicVideoMediaPolicy.js';
import { MUSIC_VIDEO_GRADE_PRESETS, MUSIC_VIDEO_GRADE_MAX_GRAIN } from './musicVideoGrade.js';
import { filmLookSchema } from './filmLookValidation.js';
-import { TITLE_CARD_FONTS, TITLE_CARD_LIMITS, TITLE_CARD_POSITIONS } from './musicVideoTitleCard.js';
+import { TITLE_CARD_FONTS, TITLE_CARD_LIMITS, TITLE_CARD_POSITIONS, TITLE_CARD_STYLES } from './musicVideoTitleCard.js';
import { COVER_DESIGN_OPTIONS } from './musicVideoCoverOverlay.js';
import { DISTROKID_REMEMBERED_OPTIONS } from './distrokidGenres.js';
import { CROSS_LINK_EDIT_TARGETS } from './musicVideoCrossLinks.js';
@@ -1239,6 +1239,10 @@ export const musicVideoTitleCardSchema = z.object({
font: z.enum(TITLE_CARD_FONTS).optional(),
size: z.number().min(TITLE_CARD_LIMITS.sizeMin).max(TITLE_CARD_LIMITS.sizeMax).optional(),
color: z.string().regex(/^#[0-9a-f]{6}$/i, 'color is #rrggbb').optional(),
+ style: z.enum(TITLE_CARD_STYLES).optional(),
+ // '' = the look's own colour.
+ titleColor: z.union([z.literal(''), z.string().regex(/^#[0-9a-f]{6}$/i, 'titleColor is #rrggbb')]).optional(),
+ accentColor: z.union([z.literal(''), z.string().regex(/^#[0-9a-f]{6}$/i, 'accentColor is #rrggbb')]).optional(),
}).strict();
export const musicVideoProjectCreateSchema = z.object({
diff --git a/server/services/musicVideo/composition.js b/server/services/musicVideo/composition.js
index c5fe5fcca0..b47505a0e2 100644
--- a/server/services/musicVideo/composition.js
+++ b/server/services/musicVideo/composition.js
@@ -19,6 +19,7 @@ import { normalizeMusicVideoGrade } from '../../lib/musicVideoGrade.js';
import { randomUUID } from 'crypto';
import { trimTo } from '../../lib/textUtils.js';
+import { normalizeTitleCard, titleCardRuntimeSource, titleCardVisible } from '../../lib/musicVideoTitleCard.js';
import { filmStyleIdSchema } from '../../lib/filmStyleGrammarValidation.js';
import {
musicVideoEidoverseSceneSchema,
@@ -230,11 +231,25 @@ export function renderableCues(composition, durationSec) {
.sort((a, b) => a.startSec - b.startSec);
}
+/**
+ * The opening title card (lib/musicVideoTitleCard.js) as a capture window in a
+ * composed render: a cue with no text of its own whose `titleCard` the overlay
+ * page draws with the same runtime the live preview and document renders use.
+ * Null when the card is off, empty or starts after the video ends.
+ */
+function titleCardCue(project, durationSec) {
+ if (project?.composition?.mode !== 'composed') return null;
+ const card = normalizeTitleCard(project.titleCard);
+ if (!titleCardVisible(card) || card.startSec >= durationSec) return null;
+ return { id: 'title-card', titleCard: card, startSec: card.startSec, endSec: Math.min(card.endSec, durationSec) };
+}
+
/** Shared absolute-song-time cues and style for full renders and draft excerpts. */
export function projectTypographyPlan(project, clips, sections, durationSec) {
const graphicLanguage = project.treatment?.brief?.graphicLanguage;
+ const titleCard = titleCardCue(project, durationSec);
return {
- cues: [...renderableCues(project.composition, durationSec), ...sectionCardCues(clips, sections, durationSec, graphicLanguage)]
+ cues: [...renderableCues(project.composition, durationSec), ...sectionCardCues(clips, sections, durationSec, graphicLanguage), ...(titleCard ? [titleCard] : [])]
.sort((a, b) => a.startSec - b.startSec),
style: { ...project.composition?.style, graphicLanguage },
};
@@ -344,12 +359,15 @@ 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, words, card }) => ({ id, text, startSec, endSec, template, placement, emphasis, ...(words ? { words } : {}), ...(card ? { card: true } : {}) }));
+ // The title card is drawn by its own runtime (installed ahead of the page's script), not as a text cue.
+ const titleCard = cues.find((cue) => cue.titleCard)?.titleCard || null;
+ const payload = cues.filter((cue) => !cue.titleCard).map(({ id, text, startSec, endSec, template, placement, emphasis, words, card }) => ({ id, text, startSec, endSec, template, placement, emphasis, ...(words ? { words } : {}), ...(card ? { card: true } : {}) }));
const hud = /\b(hud|counters?)\b/i.test(style.graphicLanguage || '');
const color = /^#[0-9a-f]{6}$/i.test(style.color || '') ? style.color : '#ffffff';
const fontStack = hud ? FONT_STACKS.mono : (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>
+ const titleCardScript = titleCard ? `<script>${titleCardRuntimeSource(titleCard)}</script>` : '';
+ return `<!doctype html><html><head><meta charset="utf-8">${titleCardScript}<style>
@font-face { font-family: "MV Archivo"; src: url(${LYRIC_FONT_FILE}) format("woff2"); font-weight: 100 900; font-stretch: 62% 125%; }
html, body { margin: 0; padding: 0; background: transparent; overflow: hidden; }
#safe { position: absolute; }
diff --git a/server/services/musicVideo/composition.test.js b/server/services/musicVideo/composition.test.js
index ece2df260c..8718a1fa48 100644
--- a/server/services/musicVideo/composition.test.js
+++ b/server/services/musicVideo/composition.test.js
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
-import { buildTypographyDocument, cueStateAt, normalizeComposition, overlayWindows, renderableCues, sectionCardCues } from './composition.js';
+import { buildTypographyDocument, cueStateAt, normalizeComposition, overlayWindows, projectTypographyPlan, renderableCues, sectionCardCues } from './composition.js';
const cue = (over = {}) => ({ id: 'c', text: 'Hello world', startSec: 10, endSec: 12, template: 'fade', placement: 'lower', emphasis: 'subtitle', ...over });
@@ -100,6 +100,24 @@ describe('card cues (#11185)', () => {
});
});
+describe('opening title card in composed renders', () => {
+ const titleCard = { enabled: true, title: 'Example Song', artist: 'Example Artist', year: '2026', startSec: 1, endSec: 6 };
+
+ it('is a capture window drawn by the title card runtime, not a text cue', () => {
+ const plan = projectTypographyPlan({ composition: { mode: 'composed' }, titleCard }, [], [], 10);
+ const cue = plan.cues.find((c) => c.titleCard);
+ expect(cue).toMatchObject({ startSec: 1, endSec: 6, titleCard: { title: 'Example Song' } });
+ const html = buildTypographyDocument({ cues: plan.cues, width: 1280, height: 720, durationSec: 10, fps: 24 });
+ expect(html).toContain('__portosTitleCard');
+ expect(html).not.toContain('"id":"title-card"');
+ });
+
+ it('is left out when the project is not composed or the card is off', () => {
+ expect(projectTypographyPlan({ composition: { mode: 'footage' }, titleCard }, [], [], 10).cues).toEqual([]);
+ expect(projectTypographyPlan({ composition: { mode: 'composed' }, titleCard: { ...titleCard, enabled: false } }, [], [], 10).cues).toEqual([]);
+ });
+});
+
describe('buildTypographyDocument (#8984)', () => {
it('embeds cue text as inert data that cannot close the script element', () => {
const html = buildTypographyDocument({ cues: [cue({ text: '</script><img src=x onerror=alert(1)>' })], width: 1920, height: 1080, durationSec: 30, fps: 24 });
diff --git a/server/services/musicVideo/compositionRender.js b/server/services/musicVideo/compositionRender.js
index 8e49822e82..2e575266ad 100644
--- a/server/services/musicVideo/compositionRender.js
+++ b/server/services/musicVideo/compositionRender.js
@@ -143,7 +143,7 @@ export async function renderTypographyOverlays({ jobId, cues, style, width, heig
const root = scratchPath(jobId);
await mkdir(join(root, 'doc'), { recursive: true });
await writeFile(join(root, 'doc', 'index.html'), buildTypographyDocument({ cues, style, width, height, durationSec, fps }));
- if (cues.some((c) => c.card)) await copyFile(LYRIC_FONT_SOURCE, join(root, 'doc', LYRIC_FONT_FILE));
+ if (cues.some((c) => c.card || c.titleCard)) await copyFile(LYRIC_FONT_SOURCE, join(root, 'doc', LYRIC_FONT_FILE));
signal?.throwIfAborted();
// Lazy: the composition browser drags in browserService, which only a
// composed render needs — not every suite that reaches render.js.
diff --git a/server/services/musicVideo/compositionRender.test.js b/server/services/musicVideo/compositionRender.test.js
index 1fd27d0a0f..332e938e6e 100644
--- a/server/services/musicVideo/compositionRender.test.js
+++ b/server/services/musicVideo/compositionRender.test.js
@@ -9,7 +9,7 @@ import { findFfmpeg, probeVideoDuration } from '../../lib/ffmpeg.js';
import { PATHS } from '../../lib/fileUtils.js';
import { _cleanupTestBrowser } from '../htmlComposition/testBrowserCleanup.js';
import { beatSnapClips, buildMusicVideoFfmpegArgs, resolveSceneClips } from './render.js';
-import { renderableCues, sectionCardCues } from './composition.js';
+import { projectTypographyPlan, renderableCues, sectionCardCues } from './composition.js';
import { COMPOSITION_SCRATCH_DIR, removeCompositionScratch, renderTypographyOverlays } from './compositionRender.js';
let endpoint;
@@ -242,6 +242,31 @@ describe.skipIf(!chrome || !ffmpeg)('music-video typography overlay with real Ch
await removeCompositionScratch('job-card');
}, 60000);
+ // The opening title card reaches composed renders: the overlay page draws it
+ // with the same runtime as the live preview, in its lower-left corner.
+ it('draws the opening title card over a composed render, lower left', async () => {
+ const [w, h] = [384, 216];
+ const project = { composition: { mode: 'composed' }, titleCard: {
+ enabled: true, title: 'Example Song', artist: 'Example Artist', year: '2026', style: 'mtv',
+ position: 'lower-left', startSec: 0, endSec: 2, fadeSec: 0.25 } };
+ const { cues, style } = projectTypographyPlan(project, [], [], 2);
+ const overlays = await renderTypographyOverlays({ jobId: 'job-title-card', cues, style, width: w, height: h, fps: 12, durationSec: 2 });
+ expect(overlays).toHaveLength(1);
+ const raw = frames(overlays[0].path, 'rgba');
+ const frame = raw.subarray(12 * w * h * 4, 13 * w * h * 4);
+ let lowerLeft = 0;
+ let elsewhere = 0;
+ for (let p = 0; p < w * h; p++) {
+ if (frame[p * 4 + 3] < 128) continue;
+ const [x, y] = [p % w, Math.floor(p / w)];
+ if (x < w / 2 && y > h / 2) lowerLeft += 1;
+ else elsewhere += 1;
+ }
+ expect(lowerLeft).toBeGreaterThan(1000);
+ expect(elsewhere).toBe(0);
+ await removeCompositionScratch('job-title-card');
+ }, 60000);
+
it.each([['16:9', 480, 270], ['9:16', 270, 480], ['a small 16:9 frame', 160, 90]])('keeps every motion template inside the title-safe area at %s', async (_label, width, height) => {
const long = 'A deliberately long lyric line that has to wrap and shrink to stay inside the frame';
const cues = [