Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ tablet, browser window, full screen, or no device at all with the text centered)
- **Background scenery**: rings, blurred colors, aurora, grid, color gradient, spotlight or plain, and the background can change during the video with a crossfade
- **Headline effects**: every headline can come in (up, from above, fade, pop, from the left, sharpen) and go out (up, down, fade, blur, shrink, to the right) in its own way, or the same for all texts at once
- **Zooms** onto a point you click, and **taps / clicks** that show where to look
- **Captions** in four styles (pop, karaoke, block, classic), made from the voice-over, from any audio track with
- **Captions** in five styles (pop, karaoke, highlighter, block, classic), made from the voice-over, from any audio track with
**speech recognition** (Whisper, on your own computer, every word at its exact moment) or imported from `.srt`/`.vtt`
- **Voice-over** from text (Kokoro / Piper TTS), plus a **music bed** that fades, ducks under the voice and
carves an EQ pocket for it, so speech stays clear while the music stays full
Expand Down
2 changes: 1 addition & 1 deletion docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pause, after a sentence end, or when it gets long). The job returns the blocks;
with `commit`, so undo works.

The style comes from `captionDefaults` < `brand.captions` < `video.captions`. It covers:
- `style` (`pop`, `karaoke`, `box`, `plain`)
- `style` (`pop`, `karaoke`, `highlighter`, `box`, `plain`)
- `y` and `size`
- `words` (per group)
- `upper` and `outline`
Expand Down
2 changes: 2 additions & 0 deletions src/captions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
export const captionStyles = {
pop: 'Pop',
karaoke: 'Karaoke',
highlighter: 'Markeerstift',
box: 'Blok',
plain: 'Klassiek'
};
export const captionStyleHints = {
pop: 'Woorden springen er één voor één in, het gesproken woord licht op.',
karaoke: 'De hele groep staat er, gesproken woorden kleuren mee.',
highlighter: 'Een markeerstreep veegt achter elk gesproken woord.',
box: 'Het gesproken woord krijgt een gekleurd blok (TikTok-stijl).',
plain: 'Rustige ondertitel met achtergrond, hele groep in één keer.'
};
Expand Down
10 changes: 9 additions & 1 deletion src/template.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export function build(v, brand, fmt = '9:16') {
const capMap = FH / H, capSize = F.area ? Math.min(1, capMap * 1.25) : 1;
const capK = Math.max(2, Math.round(cs.size * capSize * 0.055));
const capShadow = cs.outline ? [[1, 0], [-1, 0], [0, 1], [0, -1], [0.7, 0.7], [-0.7, 0.7], [0.7, -0.7], [-0.7, -0.7]].map(([x, y]) => `${Math.round(x * capK)}px ${Math.round(y * capK)}px 0 #000`).join(', ') + `, 0 ${capK}px ${capK * 4}px #000a` : 'none';
const captions = capGroups.map((g, i) => `<div id="cap${i}" class="cap"><span class="cap-bg"><span class="cap-line">${g.words.map((w, j) => `<span id="cap${i}-${j}" class="cw${w.em ? ' em' : ''}">${esc(w.w)}</span>`).join(' ')}</span></span></div>`).join('\n ');
const captions = capGroups.map((g, i) => `<div id="cap${i}" class="cap"><span class="cap-bg"><span class="cap-line">${g.words.map((w, j) => `<span id="cap${i}-${j}" class="cw${w.em ? ' em' : ''}"><span class="cw-marker"></span>${esc(w.w)}</span>`).join(' ')}</span></span></div>`).join('\n ');
// The device comes in at the start with its layout's entrance. A video that opens with only text has none: the device
// arrives with the transition of the change that brings it in.
const enter = TEXT0 || layouts[L].enter === 'none' ? '' : layouts[L].enter === 'fade'
Expand Down Expand Up @@ -465,6 +465,11 @@ export function build(v, brand, fmt = '9:16') {
tl.set(w, { color: CAP.hi }, t); tl.set(w, { color: base }, next);
} else if (CAP.style === 'karaoke') {
tl.set(w, { opacity: 1, color: CAP.hi }, t); tl.set(w, { color: base }, next);
} else if (CAP.style === 'highlighter') {
const marker = w.querySelector('.cw-marker');
tl.fromTo(marker, { scaleX: 0 }, { scaleX: 1, duration: Math.min(0.22, next - t), ease: 'power1.out', immediateRender: false }, t);
tl.set(w, { color: CAP.ink }, t); tl.set(w, { color: base }, next);
tl.set(marker, { scaleX: 0 }, next);
} else if (CAP.style === 'box') {
tl.set(w, { backgroundColor: CAP.hi, color: CAP.ink, textShadow: 'none', scale: 1.08 }, t);
tl.set(w, { backgroundColor: 'rgba(0,0,0,0)', color: base, textShadow: CAP.shadow, scale: 1 }, next);
Expand Down Expand Up @@ -637,6 +642,9 @@ export function build(v, brand, fmt = '9:16') {
.cap { position: absolute; left: 0; right: 0; top: 0; height: 0; display: flex; align-items: center; justify-content: center; opacity: 0; }
.cap-bg { display: block; max-width: 100%; text-align: center; font-size: ${Math.round(cs.size * capSize)}px; font-weight: 820; line-height: 1.14; letter-spacing: -0.02em; color: ${capColor}; text-wrap: balance;${cs.upper ? ' text-transform: uppercase;' : ''} }
.cw { display: inline-block; padding: 0.02em 0.14em; margin: 0 -0.06em; border-radius: 0.2em; text-shadow: ${capShadow}; }
.cw-marker { display: none; }
.S-highlighter .cw { position: relative; isolation: isolate; }
.S-highlighter .cw-marker { display: block; position: absolute; z-index: -1; inset: 0; border-radius: 0.16em; background: ${capHi}; transform: scaleX(0); transform-origin: left center; }
.cw.em { color: ${capHi}; }
.S-pop .cw { opacity: 0; }
.S-karaoke .cw { opacity: 0.45; }
Expand Down
8 changes: 8 additions & 0 deletions test/template.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ test('build: every layout in every format gives a page of the right size', () =>
}
});

test('build: highlighter captions sweep behind each timed word and restore the text color', () => {
const html = build(video({ captions: { style: 'highlighter' } }), brand, '9:16');
assert.match(html, /class="cw-marker"/);
assert.match(html, /\.S-highlighter \.cw-marker/);
assert.match(html, /scaleX: 1, duration: Math\.min\(0\.22, next - t\)/);
assert.match(html, /color: CAP\.ink/);
});

test('stageFit: 9:16 is the stage itself; other formats put the device box inside their area', () => {
for (const L of Object.keys(layouts)) assert.equal(stageFit('9:16', L), null);
for (const [fmt, F] of Object.entries(formats)) {
Expand Down
3 changes: 2 additions & 1 deletion ui/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,12 @@ body.electron #bar button, body.electron #bar select, body.electron #bar input,
/* captions */
.tl-item.k-sub { background: #1c2a33; color: #bfe6ff; border-color: #2a4150; }
.tl-item.k-sub.off { opacity: .45; border-style: dashed; }
.layout-grid.cap-styles { grid-template-columns: repeat(4, 1fr); }
.layout-grid.cap-styles { grid-template-columns: repeat(5, 1fr); }
.cap-demo { display: flex; align-items: baseline; gap: 1px; font-size: 16px; font-weight: 800; font-style: normal; line-height: 1; padding: 2px 4px; border-radius: 5px; }
.cap-demo b, .cap-demo i { font-style: normal; font-weight: 800; padding: 1px 2px; border-radius: 4px; }
.cap-demo.s-pop b { color: var(--accent); transform: scale(1.15); display: inline-block; } .cap-demo.s-pop i { opacity: .25; }
.cap-demo.s-karaoke b { color: var(--accent); } .cap-demo.s-karaoke i { opacity: .45; }
.cap-demo.s-highlighter b { background: linear-gradient(transparent 45%, var(--accent) 45%); }
.cap-demo.s-box b { background: var(--accent); color: #17244a; }
.cap-demo.s-plain { background: #000a; }

Expand Down
3 changes: 2 additions & 1 deletion ui/i18n.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.