Skip to content
Cutfac

How to make animated word-by-word captions with Remotion and Claude Code

Remotion makes video from React code: every frame is a web page, so text can move however code can describe it. That suits a coding agent well. This guide follows one real run: the vertical Shibuya Crossing clip from the previous guide goes in, and three versions with word-by-word captions come out, pop, highlight and box, to compare and pick from. Each step shows the command or code, what it printed, and what the Remotion piece behind it does.

Published:

Beforevertical.mp4, the starting clip: 1080 × 1920, 15 seconds and silent, with no captions yet.
AfterThe highlight version, picked from three styles: the whole line shows and the current word turns yellow.

What we're making

The starting point is vertical.mp4, the 1080 × 1920 clip made in “Claude Code video editing: how to make Shorts, Reels and TikToks”, before its caption was added. It's 15 seconds of a CC0 time-lapse of Shibuya Crossing in Tokyo, with no sound.

The goal is three lines of caption that appear word by word as the lights change and the crowd crosses, in three styles to choose from. The one that was picked, the highlight style, is at the top of the page next to the clip it started from.

Every command, output and frame below comes from that run. If you don't have vertical.mp4, any vertical clip works; only the caption timings change.

What you need

Node.js, Claude Code signed in with your own account, and a folder with vertical.mp4 and the font file. Here's what each part does:

  • Claude Code: the agent. It writes the React files, runs Remotion's commands and looks at the frames they produce.
  • Remotion: a framework that turns React components into MP4 files. It renders each frame in a headless browser and encodes them with a bundled ffmpeg, so there's nothing else to install.
  • Remotion Agent Skills: instructions that teach Claude Code how to write Remotion code, such as how timing and captions work. They install into the project folder.
  • Pretendard Bold (Pretendard-Bold.otf): the caption font, free under the SIL Open Font License.
  • Remotion has its own license, not an open-source one. It's free for individuals, non-profits and for-profit companies of up to three employees; larger companies need a company license.

Step 1: Create the project and add the skills

Remotion's project starter sets up a React app with one empty video. --blank skips the example animations and --yes accepts the defaults:

npx create-video@latest --yes --blank shibuya-captionscd shibuya-captions

Next, the Agent Skills. The skills command copies 12 skill folders into .claude/skills, where Claude Code picks them up the next time it starts in this folder. It ends with a reminder to review skills before use, since they run with the agent's permissions; they're plain Markdown, so a quick read is easy.

npx skills add remotion-dev/skills -a claude-code -yls .claude/skills
remotion-best-practices  remotion-docs           remotion-markup      remotion-saas
remotion-captions        remotion-interactivity  remotion-multimedia  remotion-studio
remotion-create          remotion-maps           remotion-render      remotion-upgrade

Last, two Remotion packages and the files. @remotion/captions groups timed words into on-screen lines, and @remotion/media plays the clip inside the video. Anything in public/ can be loaded from code with staticFile().

npx remotion add @remotion/captions @remotion/mediacp ../vertical.mp4 ../Pretendard-Bold.otf public/

Step 2: Brief Claude Code

Open Claude Code in shibuya-captions. Instead of asking for one style and judging it alone, ask for three, built from the same captions, so you can compare them side by side:

Claude Code

public/vertical.mp4 is a 15-second vertical time-lapse of Shibuya Crossing with no sound. Add word-by-word animated captions with Remotion: - Three lines: “Shibuya Crossing, Tokyo” at 0.6s, “The cars stop, the crowd goes” at 3.3s, “And here it comes again” at 11.4s - Three looks from the same captions: pop (each word springs in), highlight (the line shows and the current word turns yellow), box (the line slides up in a dark box) - Pretendard-Bold.otf, keep text clear of the bottom where the app's buttons sit - One composition per look, 1080 × 1920 at 30 fps, then render each and show me a frame

The timings come from the frames of the previous guide: cars and buses until about 3 seconds, the crowd crossing from about 3 to 6, and the second wave starting around 11 to 12. The skills tell Claude Code how to build each part, so the brief only says what the video should be.

Step 3: Write the captions as timed words

Claude Code first put the words in their own file, src/captions.ts. Each word has a start and end time in milliseconds, in the Caption shape @remotion/captions expects, and the leading space is part of the word so the line reads correctly when joined:

// [word, start ms, end ms]const line = (list: [string, number, number][]): Caption[] =>  list.map(([text, startMs, endMs]) => ({    text, startMs, endMs, timestampMs: startMs, confidence: null,  }));export const captions = {  en: [    line([      ["Shibuya", 600, 1200],      [" Crossing,", 1200, 1900],      [" Tokyo", 1900, 2800],    ]),    line([      ["The", 3300, 3600],      [" cars", 3600, 4000],      [" stop,", 4000, 4600],      [" the", 4600, 4900],      [" crowd", 4900, 5400],      [" goes", 5400, 6800],    ]),    // ...  ],};

Keeping the words apart from the styles means one file to edit when the wording or timing changes, and all three versions follow. For a clip with speech, Remotion's captions skill also covers making this list from a transcription instead of by hand.

Step 4: One component, three looks

createTikTokStyleCaptions() turns the words into pages: one page is what's on screen at once, and each token in it keeps its own time. Every look is a small React component that draws one page. The highlight look compares the current time with each word's time and colors the one being said:

const HighlightPage = ({ page }: { page: TikTokPage }) => {  const frame = useCurrentFrame();  const { fps } = useVideoConfig();  const nowMs = page.startMs + (frame / fps) * 1000;  return (    <div style={textStyle}>      {page.tokens.map((t) => {        const active = nowMs >= t.fromMs && nowMs < t.toMs;        return (          <span            key={t.fromMs}            style={{ whiteSpace: "pre", color: active ? "#FFD84D" : "white" }}          >            {t.text}          </span>        );      })}    </div>  );};

useCurrentFrame() is the heart of Remotion: it returns the frame being drawn, and the component draws that moment. The pop look uses spring(), which turns the frame count into a value that eases from 0 to 1 with a small bounce, and maps it to each word's size and position. The box look uses the same spring with heavy damping, so the box slides in without bouncing.

const s = spring({ frame: frame - start, fps, config: { damping: 12 } });// s goes from 0 to 1, overshoots a little and settlesconst transform = `translateY(${(1 - s) * 30}px) scale(${0.6 + s * 0.4})`

Each page sits in a <Sequence>, which shows it only between its start and end frames. Then the three looks are registered as three compositions with the same component and a different look prop. Remotion lists them:

npx remotion compositions
shibuya-pop          30      1080x1920      450 (15.00 sec)
shibuya-highlight    30      1080x1920      450 (15.00 sec)
shibuya-box          30      1080x1920      450 (15.00 sec)

450 frames at 30 fps is the clip's full 15 seconds. The first Remotion command also downloads a headless Chrome for rendering, about 170 MB, once.

Step 5: Render, check a frame and fix

remotion render makes the MP4; --props picks the look and language. remotion still renders a single frame as an image, which is how Claude Code looks at the result. Frame 150 is 5 seconds, the middle of the second line:

npx remotion render shibuya-highlight out/highlight-en.mp4 --props='{"look":"highlight","lang":"en"}'npx remotion still shibuya-highlight out/check.png --frame=150 --props='{"look":"highlight","lang":"en"}'
Left, the first try at 5 seconds: cars stop, the crowd goes, running off the right edge with The missing. Right, the fixed frame: The cars stop, the crowd goes, on two lines.
Frame 150. Left, the first try: “The” is missing and the line runs off the screen. Right, after the fix.

Two bugs, both silent; the render finished without an error. First, the first try put every word in one list and let createTikTokStyleCaptions() split it into pages. It starts a new page only at a word that begins with a space, once the time window has passed, and the first word of a line has no space, so “The” stuck to the end of the first line and “And” to the end of this one. Second, the highlight look sets whiteSpace: "pre" on every word so its leading space shows, and that also means the line can never wrap. A longer line simply runs off the screen.

The fix groups each line in captions.ts on its own, with a window wide enough that its words always stay together, and switches to pre-wrap, which keeps the spaces but lets the line wrap between words:

// one page per line: each line is grouped on its ownconst list = captions[lang].flatMap(  (line) =>    createTikTokStyleCaptions({ captions: line, combineTokensWithinMilliseconds: 10_000 }).pages,);// HighlightPage: let a long line wrap between wordsstyle={{ whiteSpace: "pre-wrap", color: active ? "#FFD84D" : "white" }}

The same still now reads “The cars stop, the crowd goes” on two lines. One render takes about 14 seconds on the Mac used here, so checking a frame after each change is cheap.

Step 6: Look at it in Remotion Studio

Remotion Studio is a preview in the browser. It plays a composition, lets you scrub the timeline frame by frame, and shows the props, look and lang, which you can change to see another version without touching code.

npm run dev
Remotion Studio with shibuya-highlight open at 2 seconds: the caption Shibuya Crossing, Tokyo with Tokyo in yellow, the props panel and the timeline.
Remotion Studio at 2 seconds. Tokyo is the current word, so it's yellow.

Studio is where a person checks the feel. Claude Code can't watch it, so for its own checks it renders.

Step 7: Compare the three and pick one

With the bugs fixed, Claude Code rendered all three looks and the same moment from each, at 12.5 seconds, as the second wave starts:

for look in pop highlight box; do  npx remotion render shibuya-$look out/$look-en.mp4 --props='{"look":"'$look'","lang":"en"}'done
The same frame in three styles: pop with And here it comes so far, highlight with the full line and comes in yellow, and the full line in a dark rounded box.
Pop, highlight and box at 12.5 seconds, left to right.

Pop has the most energy, but the words jump as they arrive, which is a lot over a crowd that's already moving. Box is the easiest to read over anything, but the line just sits there. Highlight shows the whole line at once and moves only the yellow word, so it reads easily and still follows the timing. That's the one at the top of this guide.

That choice took a look, not a rewrite: the three versions came from one component and a prop. Asking for a fourth, say highlight with a box behind it, is one more prompt.

Where it gets hard

The fix in step 5 started from a sentence: “at 5 seconds the line runs off the screen and a word is missing.” Picking a version meant opening three files at the same moment. With more videos and more versions, finding the frame and describing it in words is most of the work.

Cutfac is a Mac app we make for that part. It runs Claude Code or Codex for each video, lets you select a range or draw a box on the frame and say what to change, and keeps versions side by side to compare and pick from. You can do everything in this guide without it.

Free tools for this

Sources

Questions