Skip to content

<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 ​

proptypedefaultrequireddescription
idstringyesThe captions' name.
srcstringGenerate children from the asset's transcript. Literal <Caption> children override this.
stylestring |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.
xnumberWhere 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.
ynumberPixels below the frame's centre for the middle of the captions, as x.
widthnumber (> 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.
maxCharsinteger (> 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).
maxDurationnumber (> 0)5The longest a generated cue may stay on screen, in seconds.
maxGapnumber (0..∞)0.8A pause longer than this, in seconds, starts a new cue.
breakAfterstring[]Words a generated cue always ends after, as word:N refs on src: breakAfter={["word:5", "word:12"]}.

Visual. Children: caption. All elements

MIT licensed.