Get the word times
ultrafast doesn't listen to audio. It draws captions from word times you give it: a Whisper transcript with word timestamps, an SRT or VTT file, or plain lines of start end word. For speech you recorded, run Whisper first. This script uses faster-whisper:
# words.py: word times for ultrafast's captions op, from faster-whisper.
# pip install faster-whisper then: python words.py voyager.mp4 words.json
import json, sys
from faster_whisper import WhisperModel
model = WhisperModel("large-v3-turbo", device="cuda", compute_type="float16") # or device="cpu", compute_type="int8"
segments, info = model.transcribe(sys.argv[1], word_timestamps=True, vad_filter=True)
out = {"segments": [{"start": s.start, "end": s.end, "text": s.text,
"words": [{"word": w.word, "start": w.start, "end": w.end} for w in s.words]}
for s in segments]}
json.dump(out, open(sys.argv[2], "w"), indent=1)
print(sum(len(s["words"]) for s in out["segments"]), "words")$ python words.py voyager.mp4 words.json
264 words- The 112.5-second message took 2.7 s from Enter to file on an RTX 5090, and 12.6 s on the same machine's CPU with
device="cpu". The first run also downloads the model, 1.6 GB. - Keep
vad_filter=True. Without it, Whisper wrote "Go Voyager 2!" seven times over the cheering at the end, which nobody says, and the word count changed from run to run (274, 282, 287). With it: 264 words, the same on every run. - On 24 Nov 2026,
pip install faster-whisperpicked PyAV 19, which faster-whisper 1.2.1 can't open files with ("unexpected keyword argument 'metadata_errors'"). Install it withpip install faster-whisper "av<19". On an NVIDIA GPU it also needs cuBLAS and cuDNN 9; faster-whisper's README lists the pip packages. - The JSON is the shape openai-whisper writes with
--word_timestamps True, so its.jsonoutput works as it is. Any JSON whose objects have awordortextwithstartandendworks too. - Read the transcript before you render. Names, numbers and capitals after a comma are where Whisper slips.
Caption a vertical clip
Transcribe the whole recording once, then cut as many clips from it as you like. This document takes 18.5 seconds from 48.3 s into the message, crops the 16:9 footage to fill a 9:16 frame, and captions it:
{
"version": 1,
"format": { "width": 1080, "height": 1920, "fps": 30, "duration": 18.5 },
"output": "out",
"nodes": {
"footage": { "op": "video", "params": { "src": "voyager.mp4", "start": 48.3, "fit": "cover" } },
"voice": { "op": "audio", "params": { "src": "voyager.mp4", "start": 48.3 } },
"words": { "op": "captions",
"params": { "src": "words.json", "style": "karaoke", "uppercase": true,
"font": "ultrafast:sans", "weight": 800, "size": 76, "highlight": "#ffd23f" },
"timing": { "offset": -48.3 } },
"edge": { "op": "stroke_outline", "params": { "color": "#000000", "width": 5 }, "inputs": { "source": "words" } },
"shade": { "op": "drop_shadow", "params": { "offset": [0, 6], "radius": 18, "opacity": 0.7 }, "inputs": { "source": "edge" } },
"out": { "op": "over", "inputs": { "fg": "shade", "bg": "footage" } }
}
}$ uf export vertical.json vertical.mp4
exported 555 frames (1080x1920 @ 30 fps, mp4 h264, standard) in 3.09 s = 180 fps, 0 readbacks -> vertical.mp4starton the video and the audio picks where the clip begins in the source."timing": {"offset": -48.3}shifts the captions by the same amount, so the transcript's times line up with the clip. To cut another clip, change those three numbers andduration."fit": "cover"fills the frame and crops the sides of the 16:9 footage. For a different crop, give the video arectlarger than the frame and move it.- The outline and the shadow keep white words readable on the bright shots (the golden record, the Milky Way). They are two ordinary nodes on the captions layer, so any effect can go there.
- Every word is its own text node, laid out once per page, so a page is set in place before the first word lights up and nothing jumps as the speaker goes on.
Start the clip on its first word. At 48.0 s instead of 48.3 s, the last page of the sentence before ("…the other reaches ever outward.") stayed on screen for the first 0.3 s, because a page lingers 0.6 s after its last word. uf review reported it (see Check before posting).
Four styles
style, from one document with four captions nodes.style | What it does | Colours it uses |
|---|---|---|
karaoke (default) | The whole page shows; the word being spoken lights up and swells slightly | color for words to come, highlight for the spoken word, spoken for words already said |
pop | Each word pops on as it is spoken | highlight while it is spoken, then spoken |
reveal | Each word fades on as it is spoken | color |
plain | Whole pages, like ordinary subtitles | color |
Two more options change the look in every style: highlight_background puts a rounded pill behind the spoken word, and background puts a rounded box behind each page, as in the plain panel above ("#000000b0").
From an SRT or VTT file
An SRT or VTT file works in the same src. This burns NASA's own SRT into the whole 112.5-second film:
{
"version": 1,
"format": { "width": 1920, "height": 1080, "fps": 30, "duration": 112.5 },
"output": "out",
"nodes": {
"footage": { "op": "video", "params": { "src": "voyager.mp4" } },
"voice": { "op": "audio", "params": { "src": "voyager.mp4" } },
"subtitles": { "op": "captions",
"params": { "src": "voyager.srt", "style": "plain", "font": "ultrafast:sans",
"weight": 600, "size": 46, "background": "#000000b0", "position": [960, 940] } },
"out": { "op": "over", "inputs": { "fg": "subtitles", "bg": "footage" } }
}
}$ uf export film.json film.mp4
exported 3375 frames (1920x1080 @ 30 fps, mp4 h264, standard) in 17.17 s = 197 fps, 0 readbacks -> film.mp4A subtitle file has times for each cue, not for each word, so ultrafast shares a cue's time among its words by their length. On this film, those estimated word starts were within 0.25 s of Whisper's for 201 of the 259 words found in both, with a median gap of 0.12 s and the largest 0.72 s. That's fine for plain and reveal. For a karaoke highlight that lands on each syllable, use Whisper's word times. Pages are laid out again from the words, so they don't follow the file's own cue breaks. Simple markup such as <i> and {\an8} is removed.
Font, size and placement
font: an installed family, a font file next to the document, or a built-in one such asultrafast:sans;weight100 to 900;uppercase;trackingfor extra space between letters.size: 6.5 % of the frame's short side by default (70 px on a 1080×1920 frame).widthandmax_lines: lines fill to 82 % of the frame width by default, two lines a page. A page also ends at a pause over 0.8 s, and at the end of a sentence once the page has three words. For one or two words at a time, setmax_linesto 1 and a narrowerwidth.positionandalign: the centre of the caption block, by default 72 % of the way down the frame.linger: how long a page stays after its last word, 0.6 s by default.safe: the area pages must stay inside. The default,auto, keeps them clear of the social apps' buttons and caption bar on a vertical frame and inside a 4 % margin on other frames.noneplaces them exactly atposition.
Every parameter is listed under captions in the op reference.
Check before posting
uf review renders the film and reports text that viewers would trip over: words on screen too briefly to read, text that's clipped, overlapping, too small or low in contrast, and with --safe social, text under TikTok, Reels or Shorts buttons.
$ uf review vertical.json --safe social
{
"issues": [],
"frames": 555,
"texts": 51,
"seconds": 3.44
}With the clip starting at 48.0 s, the same command listed four words, OTHER, REACHES, EVER and OUTWARD., each "readable for 0.3 s", the tail of the sentence before. Starting at 48.3 s cleared it. A coding agent working through the ultrafast MCP server gets the same report and can fix what it finds before it exports.
Export
| Document | Command | Time |
|---|---|---|
vertical.json: 18.5 s at 1080×1920 | uf export vertical.json vertical.mp4 | 3.6–3.7 s |
styles.json: 10 s at 1920×1080, four videos and four caption tracks | uf export styles.json styles.mp4 | 5.0–5.2 s |
film.json: the whole 112.5 s at 1920×1080, from the SRT | uf export film.json film.mp4 | 17.9–18.2 s |
The captions of vertical.json alone, as a transparent overlay | uf export overlay.json overlay.mov --codec prores --alpha | 4.8–4.9 s |
The check of vertical.json | uf review vertical.json --safe social | 3.6 s |
Times are wall clock from the command to the file, warm, on the same workstation as the Whisper runs, with the published 0.2.1 binary. The export lines above are what uf printed. For the overlay, overlay.json is vertical.json without the footage and voice nodes and with "output": "shade": ProRes 4444 with 12-bit alpha, to lay over the edit in another editor.
Other ways to add animated captions
- Remotion's TikTok template transcribes with Whisper.cpp and draws the captions as React components, rendered by capturing a headless Chrome page frame by frame. How browser rendering compares with ultrafast on the same videos is in Benchmarks.
- HyperFrames Studio is a desktop app: it transcribes the clip on your computer, offers 16 named caption styles, and an agent changes them when asked.
- ffmpeg's
subtitlesfilter burns an SRT or ASS file into a video with libass. ASS karaoke tags (\k) can colour words in turn, written by hand or by a script. - Caption apps such as CapCut, Submagic and VEED transcribe and caption in an editor or a web upload, one video at a time.
Use ultrafast when the captions are one layer of a video you build from a document: cut by an agent or a script, many clips from one transcript, with a check before export and the render on your own GPU. Use a caption app when you have one video and want to click through styles by eye, or Remotion if the rest of your video is already React.
Questions
How do I add word-by-word animated captions to a video from the command line?
Get word times with Whisper (faster-whisper with word_timestamps=True), then put a captions node with "src": "words.json" over a video node in an ultrafast document and run uf export. The style is karaoke, pop, reveal or plain. The engine is open source and renders on your own GPU.
Can I use an SRT or VTT file instead of a Whisper transcript?
Yes, the same src reads .srt and .vtt. A subtitle file only has times per cue, so ultrafast shares each cue's time among its words by length. On NASA's SRT for a 112.5-second film, those estimated word starts had a median gap of 0.12 s from Whisper's word times. Fine for plain subtitles; for a karaoke highlight, use word times.
Does ultrafast transcribe the audio?
No. It draws captions from word times you give it. faster-whisper wrote them for a 112.5-second clip in 2.7 s on an RTX 5090 and in 12.6 s on the CPU. Keep its vad_filter on: without it, Whisper invented words over the music at the end.
How do I keep captions clear of the TikTok, Reels and Shorts buttons?
The default "safe": "auto" keeps every page out of the area the apps cover on a vertical frame, and uf review doc.json --safe social renders the film and reports any text under it, along with words on screen too briefly to read.
Can I cut several clips from one transcript?
Yes. Set the same start on the video and audio nodes, shift the captions by the same amount with "timing": {"offset": -start}, and set the clip's duration. Start each clip on its first word, or the last page of the sentence before shows for a moment.
Can I get the captions as a transparent overlay for another editor?
Yes. Leave the footage out of the document and export with --alpha, for example to ProRes 4444 with --codec prores --alpha, then lay it over your edit.