Captions and styled text
Captions and styled text are made in the edit script; no separate speech-recognition call is needed. This page strings together steps that the script reference documents one by one.
1. Where captions come from
| Source | Call | Notes |
|---|---|---|
| The voice in a clip | AddCaptionsFromTranscript(captionTrack, clip, { style: { preset: "short-video" } }) | Uses the library’s automatic transcript of the audio or video, which has word timestamps and speakers, so captions line up word by word. No separate speech-recognition call is needed |
| A script the captions must match exactly | Caption from the voice, then AlignCaptions(captionTrack, script) | The script’s words replace the recognised ones (fixing a misheard word, for example) and the timing stays aligned; the script’s punctuation is kept as written, so remove unwanted end punctuation from the script first |
| An existing SRT or VTT | ImportCaptions(captionTrack, text) | Wording and punctuation are kept; only overlapping or too-brief timings are fixed |
| A caption file to deliver | ExportCaptions(captionTrack) |
Captions follow subtitle conventions by default: 12 characters a line on a portrait canvas and 20 otherwise, 0.6–7 s on screen, no full stop at a line end, and in-points near a cut snap to it.
2. Styles: a preset or your own
ListTextStyles() lists every preset; apply one with style: { preset: "<id>" }. Caption presets:
| id | Name | Look |
|---|---|---|
short-video | Short-video captions | Centred, very large white text, heavy black outline, yellow word highlight |
karaoke | Karaoke | Bottom white text with a yellow highlight word by word |
subtitle-outline | Outlined | White text with a black outline, no box |
subtitle-black | Boxed | White text on a translucent black box |
news-caption | News | Compact white text on a dark box |
minimal-caption | Minimal | Small white text with a light shadow |
top-caption | Top | Pinned to the top edge so the subject below stays clear |
boxed-word | Word box | White text with a black outline; the current word sits on a purple rounded box |
pop-word | Pop | Heavy white text; the current word grows and turns yellow |
fade-words | Word fade | Soft-shadow white text; each word fades in as it is spoken |
slide-up | Slide up | Outlined white text that slides in from below word by word |
bounce-word | Bounce | Outlined white text; the current word springs up and turns cyan |
typewriter | Typewriter | Monospace-feel white text on a translucent black box, revealed character by character |
uppercase-impact | Uppercase impact | Very large outlined white text, all caps, with extra tracking |
cinema | Cinema | Pale cream text, wide tracking, loose line height, light shadow |
short-video captions sit in the centre of the picture and overlap a title card, which is centred too; while a title card is on screen use a bottom style such as subtitle-outline.
Title presets: bold-outline, variety-yellow, neon, metal-gold, flame, candy, bubble, ice-blue, retro, handwritten, quote, blue-pop, outline-coral, mint, lavender, clean-title, soft-shadow.
To adjust a preset or write your own, the style fields are fontFamily, fontSize, fontWeight, color, fill (gradient), stroke / strokes (layered outlines), shadows, glow, background (box colour), highlightColor (word highlight), position (top, middle, bottom), margin, maxLines and align. For example style: { preset: "short-video", fontSize: 84, highlightColor: "#FF4D4F" }.
The rich style shape is also accepted, and it is what drives the word-by-word animations:
style.letterSpacing(pixels at a 1080-pixel frame height, -20..100, negative tightens),style.lineHeight(a multiple, 0.5..3),style.textTransform(none,uppercase,lowercase,capitalize;capitalizeupper-cases each word’s first letter, so(hellobecomes(Hello), plus the same-named flat fields.border: { width, color, opacity, radius }draws an outline on the edge of the box hugging the text;radiusdefaults tobackground.borderRadius(flatborder).animation.stylepicks the word animation andanimation.direction(left,right,up,down; defaultup) is read byslideonly:
animation.style | Meaning |
|---|---|
highlight | The current word takes active.font.color (#FFE600 if none), and any richer animation an earlier write set is cleared |
karaoke | Spoken words and the current one stay highlighted; words not yet spoken keep their colour |
pop | The current word grows from 1 to active.font.size over 120 ms and settles |
fade | Each word fades from transparent to opaque over 200 ms from its own start; words not yet spoken are hidden |
slide | Like fade, sliding in 0.4 em from direction |
bounce | The current word springs up (a 250 ms sine arc) |
typewriter | Characters appear one by one |
none | Clears the highlight and the word animation |
activedescribes the current word:active.font.color(its colour),active.font.background(a rounded box behind it),active.font.size(its size in 1080-pixel units, a zoom),active.font.opacity(folded into the colour’s opacity), andactive.stroke/active.shadow(its own outline or shadow;"none"removes it). The flat equivalents arehighlightColor,activeBackground,activeFontSize,activeStrokeandactiveShadow.
A single line can override its track: Update(id, { style: { animation: { style: "pop" } } }) changes only that line while the rest follows the track. Fields with no renderer yet are refused by name: font.style, font.background, top-level padding, background.wrap, style.wordSpacing, style.textDecoration and style.size.
3. Title cards, name straps and other templates
ListTextTemplates() lists templates and InsertTemplate(track, { template, start, slots }) inserts one. Put templates on a video track above the footage: AddTrack("video", { name: "Titles" }, 0), where index 0 is the top layer; a track added without index goes to the bottom, under the footage. Each template has a fixed length, the duration in seconds that ListTextTemplates() returns (4 s for the title card), and plays from start; start captions after it when they must not overlap.
| id | Use |
|---|---|
title-card | Opening title with a subtitle |
chapter-title | Section break |
lower-third | Name and role strap |
quote-card | A highlighted line |
data-card | One highlighted number |
dialog-bubble | Dialogue or reaction text |
label-strip | A short place or topic label |
follow-outro | Closing follow prompt and account name |
4. A complete script
// Run inside a project script (the script of POST /cut/v1/projects/{project_id}:execute).// Replace lib_main / dub with a library bound to the project and a voiced video that has a transcript.const footage = AddTrack("video", { name: "Footage" });const clip = Insert(footage, { type: "video", media: { libraryId: "lib_main", assetId: "dub" }, start: 0, length: 15 });const captions = AddTrack("caption", { name: "Captions" });AddCaptionsFromTranscript(captions, clip, { style: { preset: "subtitle-outline" } });AlignCaptions(captions, "第一集 三年了,她终于回到了长安城"); // the dialogue as written, in the voice's languageconst titles = AddTrack("video", { name: "Titles" }, 0); // index 0 is the top layer; a track added without index goes to the bottom, under the footageInsertTemplate(titles, { template: "title-card", start: 0, slots: { title: "Episode 1", subtitle: "Season one" } });Preview([1, 5]);Next steps
- Motion, transitions and speed: Add keyframes and transitions once captions are in.
- Export a video: Export the captioned video and check it.
- Clean up a talking-head recording: A full recipe that uses captions with talking-head edits.