Skip to main content

Captionv4.0.216

This is a simple data structure for a caption.

import type {Caption} from '@remotion/captions';
(alias) type Caption = { text: string; startMs: number; endMs: number; timestampMs: number | null; confidence: number | null; pageBreakAfter?: boolean; } import Caption

By establishing a standard data structure, we allow many operations that involve captions to be interoperable:

Fields​

text​

string

The text of the caption.

startMs​

number

The start time of the caption in milliseconds.

endMs​

number

The end time of the caption in milliseconds.

timestampMs​

number | null

The timestamp of the caption as a singular timestamp in milliseconds. When using @remotion/install-whisper-cpp, this is the t_dtw value. Otherwise, it is null, but may be the average of the start and end timestamps.

confidence​

number | null

A number between 0 and 1 that indicates how confident the transcription is, or null if no confidence value is available.

pageBreakAfter?v4.0.517​

boolean

When true, forces a page break after this caption.

createTikTokStyleCaptions() ends the current page after this caption, so the next caption starts a new page. serializeSrt() starts a new subtitle cue.

This field does not change caption timing. When it is false or omitted, page breaks are determined automatically.

Whitespace sensitivity​

The text field is whitespace sensitive. You should include spaces in it, ideally before each word.

While rendering, apply the white-space: pre CSS property to the container of the caption to ensure that the spaces are preserved.

Compatibility​

BrowsersServersEnvironments
Chrome
Firefox
Safari
Node.js
Bun
Serverless Functions

Caption is a TypeScript type describing plain data and has no runtime requirements.

See also​