<Captions>
Subtitles from an asset's transcript that follow the clips through every trim.
tsx
import { Captions, Clip, Composition, Track } from "@cutcraft/kit";
export default function Video() {
return (
<Composition fps={30} width={540} height={960}>
<Track id="main">
<Clip id="talk" src="asset:speaker" in="word:0" out="word:12.end" fit="cover" />
</Track>
{/* Words come from the clip's transcript and follow it through every trim. */}
<Captions id="captions" src="asset:speaker" animation="karaoke" style={{ size: 36 }} />
</Composition>
);
}Used in: Kinetic type · Captions and key points · the walkthrough · Product demo with zoom-ins · Talking-head cut · Variants from one file · Vertical clip from a podcast
Props
| prop | type | default | required | description |
|---|---|---|---|---|
id | string | yes | The captions' name. | |
src | string | Generate children from the asset's transcript. Literal <Caption> children override this. | ||
style | string | | Caption styling, or the name of a theme captions preset. | ||
animation | "none" | "word-highlight" | "word-by-word" | "karaoke" | "typewriter" | "none" | How the words appear: all at once, the word being said highlighted, word by word, karaoke or typewriter. | |
x | number | Where the middle of the captions is, in pixels right of the frame's centre and below it, as on a card or a badge. y takes the place of style.position; x alone keeps the height that names. | ||
y | number | Pixels below the frame's centre for the middle of the captions, as x. | ||
width | number (> 0) | The widest a caption line may be, in pixels. Left out: the frame, less a margin at each side. | ||
align | "left" | "center" | "right" | "justify" | Which side of that width the lines sit against. Left out: center. | ||
maxChars | integer (> 0) | The most characters on a generated cue's line. Left out: as many as fit at the caption size on this frame (at most 42). | ||
maxDuration | number (> 0) | 5 | The longest a generated cue may stay on screen, in seconds. | |
maxGap | number (0..∞) | 0.8 | A pause longer than this, in seconds, starts a new cue. | |
breakAfter | string[] | Words a generated cue always ends after, as word:N refs on src: breakAfter={["word:5", "word:12"]}. |
Visual. Children: caption. All elements