Captionv4.0.216
This is a simple data structure for a caption.
import type {Caption } from '@remotion/captions';By establishing a standard data structure, we allow many operations that involve captions to be interoperable:
- Transcribing: Using the
@remotion/install-whisper-cpp,@remotion/openai-whisper, or@remotion/elevenlabspackages - Formatting: For example, creating pages using
createTikTokStyleCaptions() - Parsing: Using the
parseSrt()function - Serializing: For example to a
.srtfile usingserializeSrt()
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.