Making clips

Captions

Burn captions into the picture from cues, WebVTT text or a WebVTT file's URL.

captions burns captions into the picture, so they show wherever the clip is posted.

await createSplice({ source, start, end, captions: '/video/interview.en.vtt' })

It takes any of:

ValueRead as
CaptionCue[]{ start, end, text } on the source's timeline, in seconds
a string from WEBVTTThe text of a WebVTT file
any other string, URLThe address of a WebVTT file, fetched (CORS applies)

Only the cues inside the clip's range are drawn. Only WebVTT is read; convert SRT first.

What's read

Timing and text. Headers, NOTE and STYLE blocks, cue ids and cue settings are skipped, cue markup (<v Speaker>, <i>) is stripped, and a cue whose timing line can't be read is dropped rather than failing the file.

The look

Bold white text on a translucent dark box per line, wrapping to fit. Sizes are fractions of the frame, so a caption looks the same at every output size.

Style

captionStyle changes any of the look; leave out what you don't change.

FieldDefaultDescription
fontFamilythe system sans-serifCSS font family
fontWeight700CSS font weight
size0.045Font size, as a fraction of the frame's height
colorwhiteText colour
background'rgba(0, 0, 0, 0.6)'The box behind each line; null for none
margin0.14Distance from the top or bottom edge, of the height
maxWidth0.86Widest a line runs before wrapping, of the width
await createSplice({
  source,
  start,
  end,
  captions,
  captionStyle: {
    fontFamily: 'Georgia, serif',
    color: '#ffd400',
    background: null,
  },
})

Position

captionPosition puts the caption block at the 'bottom' (the default), the 'top' or in the 'middle'. Top and bottom sit 14% of the frame's height in from the edge, clear of what short-form apps draw over a vertical video.

await createSplice({
  source,
  start,
  end,
  captions: '/video/interview.en.vtt',
  captionPosition: 'top',
})

When they can't be loaded

A caption file that can't be fetched, answers with an HTTP error or isn't WebVTT (an HTML error page served as 200, say) leaves the clip without captions and warns through onWarning, rather than failing the clip.

From a player

In the editor, the captions burned in are the ones the viewer has on in the player, at the position chosen in the panel, read from the <video>'s text tracks. That covers WebVTT tracks and HLS subtitles, which hls.js and Safari add as text tracks.

munsonlabs · MIT licensed · © 2026