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

Music video title card: optional showing at the end of the video (#11353)

[._.]/3207200c03ff
diff --git a/client/src/components/musicVideo/TitleCardPanel.jsx b/client/src/components/musicVideo/TitleCardPanel.jsx
index 15bb6219d7..34b8065acf 100644
--- a/client/src/components/musicVideo/TitleCardPanel.jsx
+++ b/client/src/components/musicVideo/TitleCardPanel.jsx
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { Clapperboard, Play } from 'lucide-react';
import { getMusicVideoPublishPlatforms } from '../../services/apiMusicVideo.js';
import {
- TITLE_CARD_FONT_FACES, TITLE_CARD_LIMITS, TITLE_CARD_MTV_COLORS, normalizeTitleCard, titleCardPrefill,
+ TITLE_CARD_FONT_FACES, TITLE_CARD_LIMITS, TITLE_CARD_MTV_COLORS, normalizeTitleCard, titleCardOutroWindow, 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']];
@@ -56,6 +56,7 @@ function lyricDuringCard(project, card) {
* 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.
+ * Optionally it shows again at the end (`outro`), timed from the song's length.
* Edited on the Look step, under the docked preview (a card of its own there).
*/
export default function TitleCardPanel({ project, onEditLocal, onSave, onPreview }) {
@@ -92,6 +93,10 @@ export default function TitleCardPanel({ project, onEditLocal, onSave, onPreview
const overlap = on ? lyricDuringCard(project, card) : null;
const endBefore = overlap ? Math.round((overlap.startSec - 0.5) * 10) / 10 : null;
const field = (key) => (raw?.[key] ?? card?.[key] ?? '');
+ const songSec = project.audioAnalysis?.durationSec;
+ // Turning the end showing on times it from the song's length the first time.
+ const setOutro = (outro) => commit(outro && card?.outroStartSec == null ? { outro, ...titleCardOutroWindow(card, songSec) } : { outro });
+ const canOutro = card?.outro || card?.outroStartSec != null || !!titleCardOutroWindow(card, songSec);
return (
<section aria-label="Opening title card" className="space-y-2 rounded-lg border border-port-border bg-port-card p-2">
@@ -147,6 +152,34 @@ export default function TitleCardPanel({ project, onEditLocal, onSave, onPreview
onChange={(e) => edit({ fadeSec: toNumber(e.target.value) })} onBlur={() => commit()} className={inputCls} />
</div>
</div>
+ <div className="space-y-2">
+ <label htmlFor="mv-title-card-outro" 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-outro" type="checkbox" checked={card.outro} disabled={!canOutro}
+ onChange={(e) => setOutro(e.target.checked)} className="h-4 w-4" />
+ Also at the end · Optional
+ </label>
+ {!canOutro && <p className="text-xs text-port-text-muted">Needs the song's length; analyze the song first.</p>}
+ {card.outro && (
+ <div className="grid grid-cols-3 items-end gap-2">
+ <div>
+ <label htmlFor="mv-title-card-outro-start" className={labelCls}>End in (s)</label>
+ <input id="mv-title-card-outro-start" type="number" min={0} max={TITLE_CARD_LIMITS.outroMax} step={0.1} value={field('outroStartSec')}
+ onChange={(e) => edit({ outroStartSec: toNumber(e.target.value) ?? null })} onBlur={() => commit()} className={inputCls} />
+ </div>
+ <div>
+ <label htmlFor="mv-title-card-outro-end" className={labelCls}>End out (s)</label>
+ <input id="mv-title-card-outro-end" type="number" min={0} step={0.1} value={field('outroEndSec')}
+ onChange={(e) => edit({ outroEndSec: toNumber(e.target.value) ?? null })} onBlur={() => commit()} className={inputCls} />
+ </div>
+ {onPreview && typeof card.outroStartSec === 'number' && (
+ <button type="button" onClick={() => onPreview(Math.max(0, card.outroStartSec - 0.5))}
+ className="inline-flex min-h-[44px] items-center gap-1 text-xs text-port-accent sm:min-h-0">
+ <Play size={13} aria-hidden="true" /> Play from {clock(Math.max(0, card.outroStartSec - 0.5))}
+ </button>
+ )}
+ </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}>
diff --git a/client/src/components/musicVideo/TitleCardPanel.test.jsx b/client/src/components/musicVideo/TitleCardPanel.test.jsx
index e77306e085..77f4757b81 100644
--- a/client/src/components/musicVideo/TitleCardPanel.test.jsx
+++ b/client/src/components/musicVideo/TitleCardPanel.test.jsx
@@ -74,6 +74,24 @@ describe('TitleCardPanel', () => {
expect(screen.getByLabelText('Bar')).toBeInTheDocument();
});
+ it('optionally shows the card again at the end, timed from the song length', () => {
+ const onSave = vi.fn().mockResolvedValue({});
+ const card = { enabled: true, title: 'Example Song', startSec: 2, endSec: 6 };
+ const { unmount } = render(<Harness initial={{ ...base, titleCard: card }} onSave={onSave} />);
+ expect(screen.getByLabelText(/Also at the end/)).toBeDisabled();
+ unmount();
+ render(<Harness initial={{ ...base, audioAnalysis: { durationSec: 200 }, titleCard: card }} onSave={onSave} />);
+ const outro = screen.getByLabelText(/Also at the end · Optional/);
+ expect(outro).not.toBeChecked();
+ expect(screen.queryByLabelText('End in (s)')).toBeNull();
+ fireEvent.click(outro);
+ expect(onSave).toHaveBeenLastCalledWith({ titleCard: expect.objectContaining({ outro: true, outroStartSec: 195, outroEndSec: 199 }) });
+ expect(screen.getByLabelText('End in (s)')).toHaveValue(195);
+ fireEvent.change(screen.getByLabelText('End out (s)'), { target: { value: '198' } });
+ fireEvent.blur(screen.getByLabelText('End out (s)'));
+ expect(onSave).toHaveBeenLastCalledWith({ titleCard: expect.objectContaining({ outroStartSec: 195, outroEndSec: 198 }) });
+ });
+
it('picks a font from swatches drawn in each face', () => {
const onSave = vi.fn().mockResolvedValue({});
render(<Harness initial={{ ...base, titleCard: { enabled: true, title: 'Example Song', startSec: 1, endSec: 5 } }} onSave={onSave} />);
diff --git a/docs/HTML_COMPOSITIONS.md b/docs/HTML_COMPOSITIONS.md
index d50dbf5331..0f30eb227a 100644
--- a/docs/HTML_COMPOSITIONS.md
+++ b/docs/HTML_COMPOSITIONS.md
@@ -366,7 +366,12 @@ Audiowide, Orbitron, Righteous, Pacifico, Playfair Display, files and licences
in `server/services/musicVideo/titleCardFonts/`), picked from swatches drawn in
each face. Text is drawn exactly as typed;
the panel flags a sung line that starts while the card is up and offers to end the
-card before it.
+card before it. **Also at the end** (optional, off by default: `outro`) shows the
+same card again in its own window (`outroStartSec`–`outroEndSec`, song time);
+turning it on times that window from the song's length (`titleCardOutroWindow`:
+as long as the opening one, ending a second before the song does). The runtime's
+fade covers both windows, and a composed cut gets one capture cue per window
+(`titleCardWindows`).
The card is not part of the composition document. `titleCardRuntimeSource()`
is a page script installed beside it, in the live preview's head (live edits
diff --git a/server/lib/musicVideoTitleCard.browser.test.js b/server/lib/musicVideoTitleCard.browser.test.js
index fc6f097e8c..72d2448525 100644
--- a/server/lib/musicVideoTitleCard.browser.test.js
+++ b/server/lib/musicVideoTitleCard.browser.test.js
@@ -124,6 +124,18 @@ describe.skipIf(!canRun)('title card runtime in Chrome', () => {
await other.close();
}, 30000);
+ it('shows again in its end window when the end showing is on', async () => {
+ const other = await browser.newPage({ viewport: { width: W, height: H } });
+ const card = { title: 'Example Song', artist: 'Example Artist', startSec: 2, endSec: 5, fadeSec: 0.5, outro: true, outroStartSec: 14, outroEndSec: 18 };
+ await other.setContent(`<!doctype html><html><head><style>html,body{margin:0;background:#000}</style>
+<script>${titleCardRuntimeSource(card)}</script></head><body>${DOCUMENT}</body></html>`);
+ const at = async (t) => { await other.evaluate((s) => globalThis.portosComposition.seek(s), t); return brightIn(await other.screenshot(), lowerLeft); };
+ expect(await at(10)).toBe(0);
+ expect(await at(16)).toBeGreaterThan(200);
+ expect(await at(19)).toBe(0);
+ await other.close();
+ }, 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 ea9c54d2ab..1ce205fe67 100644
--- a/server/lib/musicVideoTitleCard.js
+++ b/server/lib/musicVideoTitleCard.js
@@ -15,6 +15,8 @@
* 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.
+ * Optionally (`outro`) the same card shows again at the end of the video, in
+ * its own window (`outroStartSec`–`outroEndSec`, absolute song time).
* Text is drawn exactly as typed (no forced case).
*
* Fonts: four system/lyric stacks plus bundled OFL faces (TITLE_CARD_FONT_FACES,
@@ -44,12 +46,13 @@ 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,
+ textMax: 120, yearMax: 20, startMax: 600, windowMin: 0.5, fadeMax: 3, sizeMin: 50, sizeMax: 200, outroMax: 3600,
});
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: '',
+ outro: false, outroStartSec: null, outroEndSec: null,
});
const clampNum = (value, min, max, fallback) => {
@@ -70,6 +73,12 @@ export function normalizeTitleCard(input) {
const L = TITLE_CARD_LIMITS;
const startSec = round3(clampNum(input.startSec, 0, L.startMax, D.startSec));
const endSec = round3(Math.max(startSec + L.windowMin, clampNum(input.endSec, 0, L.startMax + 60, Math.max(D.endSec, startSec + 6))));
+ // The end showing keeps its window once timed; untimed (null) it shows nowhere.
+ const timedOutro = typeof input.outroStartSec === 'number' && Number.isFinite(input.outroStartSec);
+ const outroStartSec = timedOutro ? round3(clampNum(input.outroStartSec, 0, L.outroMax, 0)) : null;
+ const outroEndSec = timedOutro
+ ? round3(Math.max(outroStartSec + L.windowMin, clampNum(input.outroEndSec, 0, L.outroMax + 60, outroStartSec + (endSec - startSec))))
+ : null;
return {
enabled: typeof input.enabled === 'boolean' ? input.enabled : D.enabled,
title: cleanText(input.title, L.textMax),
@@ -88,9 +97,35 @@ export function normalizeTitleCard(input) {
// '' = the look's own colour (the text colour, or the mtv yellow title / cyan bar).
titleColor: hexOr(input.titleColor, ''),
accentColor: hexOr(input.accentColor, ''),
+ outro: typeof input.outro === 'boolean' ? input.outro : D.outro,
+ outroStartSec,
+ outroEndSec,
};
}
+/**
+ * The windows the card shows in: the opening one, then the end one when it is
+ * on and timed. `[{ startSec, endSec }]`, empty for a hidden card.
+ */
+export function titleCardWindows(card) {
+ if (!titleCardVisible(card)) return [];
+ const windows = [{ startSec: card.startSec, endSec: card.endSec }];
+ if (card.outro && typeof card.outroStartSec === 'number' && typeof card.outroEndSec === 'number') {
+ windows.push({ startSec: card.outroStartSec, endSec: card.outroEndSec });
+ }
+ return windows;
+}
+
+/**
+ * The end showing's default window: as long as the opening one, ending a
+ * second before the song does (never before 0). Null without a song length.
+ */
+export function titleCardOutroWindow(card, songDurationSec) {
+ if (!card || !(typeof songDurationSec === 'number' && songDurationSec > 0)) return null;
+ const endSec = round3(Math.max(TITLE_CARD_LIMITS.windowMin, songDurationSec - 1));
+ return { outroStartSec: round3(Math.max(0, endSec - (card.endSec - card.startSec))), outroEndSec: endSec };
+}
+
/** True when the card would draw something (enabled, with at least one line). */
export function titleCardVisible(card) {
return !!(card && card.enabled && [card.title, card.artist, card.year, card.extra].some((line) => String(line || '').trim()));
@@ -119,12 +154,18 @@ export function titleCardPrefill(project, { artist = '', year = new Date().getFu
* (titleCardRuntimeSource), so each must stay self-contained: no references
* to module scope, only to each other by name. */
-/** The card's opacity at song time t: a linear fade in and out inside its window (0 outside). */
+/** The card's opacity at song time t: a linear fade in and out inside its window, or its end window (0 outside). */
function titleCardAlpha(card, t) {
- if (!card || !card.enabled || !(t >= card.startSec) || !(t < card.endSec)) return 0;
- const fade = Math.min(Math.max(0, card.fadeSec || 0), (card.endSec - card.startSec) / 2);
- if (fade <= 0) return 1;
- return Math.max(0, Math.min(1, (t - card.startSec) / fade, (card.endSec - t) / fade));
+ if (!card || !card.enabled) return 0;
+ const inWindow = (startSec, endSec) => {
+ if (!(t >= startSec) || !(t < endSec)) return 0;
+ const fade = Math.min(Math.max(0, card.fadeSec || 0), (endSec - startSec) / 2);
+ if (fade <= 0) return 1;
+ return Math.max(0, Math.min(1, (t - startSec) / fade, (endSec - t) / fade));
+ };
+ const outro = card.outro && typeof card.outroStartSec === 'number' && typeof card.outroEndSec === 'number'
+ ? inWindow(card.outroStartSec, card.outroEndSec) : 0;
+ return Math.max(inWindow(card.startSec, card.endSec), outro);
}
/**
diff --git a/server/lib/musicVideoTitleCard.test.js b/server/lib/musicVideoTitleCard.test.js
index ffd572412a..e8a6fafe10 100644
--- a/server/lib/musicVideoTitleCard.test.js
+++ b/server/lib/musicVideoTitleCard.test.js
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { readFileSync } from 'node:fs';
-import { TITLE_CARD_DEFAULTS, TITLE_CARD_FONT_FACES, TITLE_CARD_FONTS, normalizeTitleCard, titleCardPrefill, titleCardVisible } from './musicVideoTitleCard.js';
+import { TITLE_CARD_DEFAULTS, TITLE_CARD_FONT_FACES, TITLE_CARD_FONTS, normalizeTitleCard, titleCardOutroWindow, titleCardPrefill, titleCardVisible, titleCardWindows } from './musicVideoTitleCard.js';
describe('normalizeTitleCard', () => {
it('fills defaults, clamps ranges and keeps the window open', () => {
@@ -22,6 +22,27 @@ describe('normalizeTitleCard', () => {
});
});
+describe('end showing', () => {
+ it('is off and untimed by default, keeps a timed window open, and adds a second window only when on', () => {
+ const card = normalizeTitleCard({ title: 'Song', startSec: 2, endSec: 6 });
+ expect(card).toMatchObject({ outro: false, outroStartSec: null, outroEndSec: null });
+ expect(titleCardWindows(card)).toEqual([{ startSec: 2, endSec: 6 }]);
+ const timed = normalizeTitleCard({ title: 'Song', startSec: 2, endSec: 6, outro: true, outroStartSec: 190 });
+ expect(timed).toMatchObject({ outroStartSec: 190, outroEndSec: 194 });
+ expect(titleCardWindows(timed)).toEqual([{ startSec: 2, endSec: 6 }, { startSec: 190, endSec: 194 }]);
+ expect(normalizeTitleCard({ outroStartSec: 10, outroEndSec: 3 }).outroEndSec).toBe(10.5);
+ expect(titleCardWindows({ ...timed, outro: false })).toHaveLength(1);
+ expect(titleCardWindows({ ...timed, enabled: false })).toEqual([]);
+ });
+
+ it('defaults the end window to the opening one\'s length, a second before the song ends', () => {
+ const card = normalizeTitleCard({ title: 'Song', startSec: 2, endSec: 6 });
+ expect(titleCardOutroWindow(card, 200)).toEqual({ outroStartSec: 195, outroEndSec: 199 });
+ expect(titleCardOutroWindow(card, 3)).toEqual({ outroStartSec: 0, outroEndSec: 2 });
+ expect(titleCardOutroWindow(card, undefined)).toBeNull();
+ });
+});
+
describe('titleCardPrefill', () => {
it('fills the song title without its version suffix, the artist and the year', () => {
expect(titleCardPrefill({ name: 'Example Song Title v3' }, { artist: 'Example Artist', year: 2026 }))
diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.js
index 6100b4522e..083cc95aa1 100644
--- a/server/lib/musicVideoValidation.js
+++ b/server/lib/musicVideoValidation.js
@@ -1299,6 +1299,10 @@ export const musicVideoTitleCardSchema = z.object({
// '' = 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(),
+ // The optional second showing at the end of the video (null = not timed yet).
+ outro: z.boolean().optional(),
+ outroStartSec: z.number().min(0).max(TITLE_CARD_LIMITS.outroMax).nullable().optional(),
+ outroEndSec: z.number().min(0).max(TITLE_CARD_LIMITS.outroMax + 60).nullable().optional(),
}).strict();
export const musicVideoProjectCreateSchema = z.object({
diff --git a/server/services/musicVideo/composition.js b/server/services/musicVideo/composition.js
index 8cefe787e7..8c2f2576ac 100644
--- a/server/services/musicVideo/composition.js
+++ b/server/services/musicVideo/composition.js
@@ -19,7 +19,7 @@ import { normalizeMusicVideoGrade } from '../../lib/musicVideoGrade.js';
import { randomUUID } from 'crypto';
import { trimTo } from '../../lib/textUtils.js';
-import { normalizeTitleCard, titleCardVisible } from '../../lib/musicVideoTitleCard.js';
+import { normalizeTitleCard, titleCardWindows } from '../../lib/musicVideoTitleCard.js';
import { titleCardRuntime } from './titleCardFonts.js';
import { filmStyleIdSchema } from '../../lib/filmStyleGrammarValidation.js';
import {
@@ -233,24 +233,25 @@ export function renderableCues(composition, durationSec) {
}
/**
- * 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.
+ * The opening title card (lib/musicVideoTitleCard.js) as capture windows in a
+ * composed render: one cue per window it shows in (the opening, and the end
+ * when that is on), with no text of its own; the overlay page draws the
+ * `titleCard` with the same runtime the live preview and document renders use.
+ * Empty when the card is off or empty; a window past the video's end is dropped.
*/
-function titleCardCue(project, durationSec) {
- if (project?.composition?.mode !== 'composed') return null;
+function titleCardCues(project, durationSec) {
+ if (project?.composition?.mode !== 'composed') return [];
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) };
+ return titleCardWindows(card)
+ .filter((w) => w.startSec < durationSec)
+ .map((w, i) => ({ id: i ? 'title-card-end' : 'title-card', titleCard: card, startSec: w.startSec, endSec: Math.min(w.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), ...(titleCard ? [titleCard] : [])]
+ cues: [...renderableCues(project.composition, durationSec), ...sectionCardCues(clips, sections, durationSec, graphicLanguage), ...titleCardCues(project, durationSec)]
.sort((a, b) => a.startSec - b.startSec),
style: { ...project.composition?.style, graphicLanguage },
};
diff --git a/server/services/musicVideo/composition.test.js b/server/services/musicVideo/composition.test.js
index 8718a1fa48..4e3afa87a9 100644
--- a/server/services/musicVideo/composition.test.js
+++ b/server/services/musicVideo/composition.test.js
@@ -116,6 +116,15 @@ describe('opening title card in composed renders', () => {
expect(projectTypographyPlan({ composition: { mode: 'footage' }, titleCard }, [], [], 10).cues).toEqual([]);
expect(projectTypographyPlan({ composition: { mode: 'composed' }, titleCard: { ...titleCard, enabled: false } }, [], [], 10).cues).toEqual([]);
});
+
+ it('adds the end showing as a second window when it is on, clipped to the cut', () => {
+ const withEnd = { ...titleCard, outro: true, outroStartSec: 7, outroEndSec: 12 };
+ const cues = projectTypographyPlan({ composition: { mode: 'composed' }, titleCard: withEnd }, [], [], 10).cues.filter((c) => c.titleCard);
+ expect(cues.map(({ id, startSec, endSec }) => ({ id, startSec, endSec }))).toEqual([
+ { id: 'title-card', startSec: 1, endSec: 6 }, { id: 'title-card-end', startSec: 7, endSec: 10 }]);
+ const past = { ...withEnd, outroStartSec: 11, outroEndSec: 14 };
+ expect(projectTypographyPlan({ composition: { mode: 'composed' }, titleCard: past }, [], [], 10).cues.filter((c) => c.titleCard)).toHaveLength(1);
+ });
});
describe('buildTypographyDocument (#8984)', () => {