Skip to content

createVideoCaptions

createVideoCaptions<T>(captionsMap): VideoCaptions<T>

Defined in: caption.ts:345

Creates caption controllers backed by pre-recorded asset files instead of TTS-generated audio. Each entry maps a name to either an asset path string or an object with assetPath and an optional subtitle text.

At render time the asset file is used directly as the voiceover audio. If subtitle is provided, words are spread with equal timing across the audio duration (no word-level TTS data available).

Same constraints as createCaptions: cannot overlap with other captions, and cannot fall inside input events.

Two overloads:

1. Single-language:

const captions = createVideoCaptions({
intro: '/assets/intro.mp3',
demo: { assetPath: '/assets/demo.mp3', subtitle: 'Watch the demo.' },
})

2. Multi-language (type-safe): TypeScript enforces that every language has the same caption keys.

const captions = createVideoCaptions({
en: { captions: { intro: '/assets/en/intro.mp3' } },
fi: { captions: { intro: '/assets/fi/intro.mp3' } },
})

T extends Record<string, VideoCaptionEntry>

T

VideoCaptions<T>

createVideoCaptions<L, T>(languagesMap): VideoCaptions<T & Record<string, VideoCaptionEntry>>

Defined in: caption.ts:348

Creates caption controllers backed by pre-recorded asset files instead of TTS-generated audio. Each entry maps a name to either an asset path string or an object with assetPath and an optional subtitle text.

At render time the asset file is used directly as the voiceover audio. If subtitle is provided, words are spread with equal timing across the audio duration (no word-level TTS data available).

Same constraints as createCaptions: cannot overlap with other captions, and cannot fall inside input events.

Two overloads:

1. Single-language:

const captions = createVideoCaptions({
intro: '/assets/intro.mp3',
demo: { assetPath: '/assets/demo.mp3', subtitle: 'Watch the demo.' },
})

2. Multi-language (type-safe): TypeScript enforces that every language has the same caption keys.

const captions = createVideoCaptions({
en: { captions: { intro: '/assets/en/intro.mp3' } },
fi: { captions: { intro: '/assets/fi/intro.mp3' } },
})

L extends "fi" | "en"

T extends Record<string, VideoCaptionEntry>

{ [K in “fi” | “en”]: { captions: T } } & RequireAllSameVideoKeys<{ [K in “fi” | “en”]: { captions: Record<string, VideoCaptionEntry> } }>

VideoCaptions<T & Record<string, VideoCaptionEntry>>