Element Reference
Subtitle Element
1. Shape
type SubtitleSource =
| SubtitleWord[]
| { $ref: string }
| { src: string };
interface SubtitleClip extends BaseClip {
type: "subtitle";
words: SubtitleSource;
config?: SubtitleConfig;
}Also supports:
opacityanimationskeyframestransitiontransformzIndex
2. SubtitleWord
interface SubtitleWord {
word: string;
punctuated_word: string;
start: number;
end: number;
confidence?: number;
}3. Supported subtitle sources
Inline array
{
"words": [
{
"word": "hello",
"punctuated_word": "Hello",
"start": 0,
"end": 0.4
}
]
}Subtitle asset via $ref
{
"words": { "$ref": "subtitle-main" }
}External URL
{
"words": { "src": "https://example.com/subtitle.json" }
}4. External subtitle URL rules
The remote endpoint must return JSON in one of these shapes:
SubtitleWord[]{ "words": SubtitleWord[] }
Public behavior:
- The preview flow accepts
words: { "src": "..." } - Preview playback normalizes subtitle data before playback
- If you send
{ src }directly into a lower-level renderer, subtitle data is not fetched automatically
5. SubtitleConfig
interface SubtitleConfig {
mode?: "batch" | "stream";
wordsPerBatch?: number;
fontSize?: number;
fontFamily?: string;
fontWeight?: number | string;
textAlign?: "left" | "center" | "right";
textBoxWidth?: number | string;
textColor?: string;
highlightColor?: string;
backgroundColor?: string;
shadowColor?: string;
shadowBlur?: number;
borderColor?: string;
borderWidth?: number;
fadeInAnimation?: boolean;
position?: "bottom" | "top" | "center";
paddingBottom?: number;
}6. Currently implemented config fields
modewordsPerBatchfontSizefontFamilyfontWeighttextAligntextBoxWidthtextColorhighlightColorbackgroundColorshadowColorshadowBlurborderColorborderWidthfadeInAnimationpositionpaddingBottom
7. Mode behavior
batch
- Displays subtitles in chunks
- Highlights the currently spoken word
stream
- Reveals words one by one
8. Whole-block animation behavior
Container-level subtitle animation applies to the full subtitle block, not to the per-word highlight logic.
Important distinction:
config.fadeInAnimationcontrols fade behavior inside subtitle batchesanimations / keyframes / transitioncontrol the whole subtitle container
That means you can animate the subtitle block itself with fade, slide, or movement without changing the internal word-highlighting logic.
9. Example
{
"type": "subtitle",
"start": 0,
"duration": 8,
"words": { "$ref": "sub-main" },
"animations": [
{ "type": "slideIn", "duration": 0.4, "direction": "up" }
],
"config": {
"position": "bottom",
"fontSize": 60,
"highlightColor": "#22d3ee",
"backgroundColor": "rgba(0,0,0,0.4)"
}
}