# Add captions to a video with code.

> Add word-timed captions to your own clip: vawe writes the word times on your machine, and you turn each word into a span. Commands and HTML included.

Canonical: https://vawe.dev/how-to/add-captions-to-video
Last updated: 2026-11-17

vawe makes a transcript of your clip with every word timed, on your machine. You turn each word into a span with its start time, and one CSS animation lights it on its second. This guide has the commands and the page.

## Copy this prompt into your agent

```
Use vawe (https://github.com/vawe-hq/vawe), the open-source video-from-code tool, to add word-by-word captions to my video.

My clip: <path to your clip or folder>.

Time every word from the transcript, show the line being spoken, and light each word on its own second. Keep the captions inside the safe area and easy to read on a phone.

If vawe is not installed here, install it first:
npm install @vawe/cli
(it needs Node 22 or newer and ffmpeg; npx vawe new prints the install line for anything missing).
Then follow each command’s next: line.

Start with npx vawe new <name> --footage <my clip>, which logs the clip with a transcript.

Show me the draft video and wait for my OK before the final render.
```

## The steps.

1. **Log the clip. **`bin/vawe new captions --footage ~/clips/talk.mov` copies it into `films/captions/footage/` and writes `footage.md` and `footage/talk.words.json`. Each entry in the words file has a word and its start and end in seconds.
2. **Set up the transcript tool once. **The words come from whisper.cpp, so there is no API key and no upload. Install it with `brew install whisper-cpp`. The first footage log prints the line for the 148 MB model if it is missing.
3. **Make one span per word. **Set `--at` to the word start, plus the clip’s `data-at`, minus its `data-trim`. Put the spans in the same world as the `<video>`.
4. **Animate the spans. **One `@keyframes` rule with `animation-delay: var(--at)` lights the word on its second. The [caption post](https://vawe.dev/blog/animated-captions-html) has the full rule.
5. **Render a draft and look. **`bin/vawe dev films/captions/page.html`, then `bin/vawe frame films/captions/page.html --at 1,3,5` for a sheet of frames at those seconds.

Words from the transcript, as spans:

```
<section data-world="talk">
  <video src="footage/talk.mp4" data-at="0"
         data-trim="0" data-trim-end="14.2"></video>
  <p class="line">
    <span class="w" style="--at:0.42s">so</span>
    <span class="w" style="--at:0.58s">today</span>
    <span class="w" style="--at:1.02s">I</span>
  </p>
</section>
<style>.w { animation: say 0.4s var(--at) both }</style>
```

Source: skills/vawe-page/SKILL.md, Video clips · blog: animated captions in HTML

## Two caption styles to copy.

One lights the word being said. The other sets key words in a contrasting face.

- [caption-karaoke](https://vawe.dev/video-components/caption-karaoke)
- [caption-editorial](https://vawe.dev/video-components/caption-editorial)

## What can go wrong.

1. **The clip has no speech. **A silent recording has no words file to read. Give the agent the text and the seconds yourself.
2. **The captions run early or late. **The clip is trimmed or starts late in the film, and the `--at` values ignore that. Add `data-at` and subtract `data-trim`.
3. **The model is missing. **The footage log prints the download line. Run it, then log the clip again.
4. **The text is too small on a vertical film. **Size the line in `--vw` or `--vh` units, as the blog page does with 9vw.

## Read next.

1. [Captions on a video, in HTML](https://vawe.dev/blog/animated-captions-html): the full page and the CSS rule, plus the section on your own footage.
2. [How an agent reads footage it cannot watch](https://vawe.dev/blog/how-an-agent-reads-footage): what the words file holds.
3. [Agentic video editing](https://vawe.dev/agentic-video-editing): the whole edit, from clips to MP4.

## Start from your clip.

`bin/vawe new <name> --footage <file>` logs it and starts the page.

## Related

- [Get vawe on GitHub](https://github.com/vawe-hq/vawe)
- [All how-to guides](https://vawe.dev/how-to)
- [Add captions to a video](https://vawe.dev/how-to/add-captions-to-video)
- [Remove silences from a video](https://vawe.dev/how-to/remove-silences-from-video)
- [Trim and join clips](https://vawe.dev/how-to/trim-and-join-video-clips)
- [Agentic video editing](https://vawe.dev/agentic-video-editing)
- [Edit video with Claude Code](https://vawe.dev/edit-video-with-claude-code)
