Architecture
OpenCaptions turns a video into a captioned one: it transcribes the speech with word timings, lets you edit and style the captions, and renders them into the video. It runs as one Docker Compose stack you host yourself, and as a native iOS app that does the same on the phone, with no server.
Services
Section titled “Services”browser ──▶ web (nginx: SPA + proxy) ──▶ api (FastAPI) ──▶ postgres │ ▲ redis (Celery broker) ▼ │ progress garage (S3 store) worker-transcription ┘ │ worker-rendering ──▶ engine (POST /render)| Service | Role |
|---|---|
web | The React SPA, and the only published port (5173). nginx proxies /api and /ws to the API, so the browser talks to one origin. |
api | REST + WebSocket API, auth, enqueueing. Migrations run on boot. |
worker-transcription | Celery queue transcription: extract audio, run the provider, store the transcript. worker-transcription-gpu is the same image on CUDA, behind the gpu profile. |
worker-rendering | Celery queue rendering: hands a render to the engine and records the result. Scales on its own (OC_RENDERERS). |
engine | The Rust render server: FFmpeg decodes, the engine draws each caption frame, FFmpeg composites and encodes. |
postgres, redis, garage | Data, broker, and the S3-compatible object store. |
Two queues, because a backlog of renders must never starve transcription, and
the two scale on different hardware. A transcription worker handles one job and exits
(--max-tasks-per-child=1), so a loaded speech model never outlives its job: an idle stack
holds none of its memory, and a CUDA failure costs one job. The price is a model load per job.
When a job fails to finish. Tasks are acknowledged late, so a task a crashed worker held
is handed to another; an API restart therefore says nothing about running work and does not
fail it. At boot only a job that cannot still be working is failed (services/recovery.py):
running with no change for longer than any task may run, or pending for a day (a message
that old is gone). Each task has its own time limits (core/task_limits.py): a render’s
follow the engine’s request timeout, a transcription’s the longest video the instance
accepts. A job that is over (completed, failed, cancelled) is never brought back by its
task’s late status updates. Progress is published to Redis over one pooled connection per
process (core/events.py).
A job, end to end
Section titled “A job, end to end”- Upload.
POST /projectsstores the source atprojects/{id}/source.<ext>, probes it (size, fps, duration, rotation, HDR transfer) and makes a thumbnail. A URL can be given instead; it is fetched with SSRF checks (http(s) only, every resolved address must be public). - Transcribe. A job on the transcription queue. Progress goes to the
project’s WebSocket. The result is a
Transcript: segments of words, each withstart,endandconfidence, and the voice’s loudness measured from the same audio for the Pulse look (app/services/loudness.py; see the engine). - Edit. The SPA edits the transcript and the style and autosaves them with
PATCH /projects/{id}. The preview is drawn by the engine in the browser, and every transcript edit is one of the engine’s (see below). Words are edited on the preview, captions are retimed on the timeline, and nothing else changes the transcript. - Render.
POST /projects/{id}/download {format, resolution, frame_rate, green_screen}computes a hash of everything that decides the output (transcript, timing offset, style, format and its encoder settings, size, fps, and the engine’s render revision: a number inapps/engine/src/render_revision.txtbumped with any change to what the engine draws, which the golden-frame test asks for, so a cached file is never from an older drawing than the preview; the engine’s/healthreports it). Ifprojects/{id}/renders/{format}/{hash}.<ext>exists it is ready at once (each format has a folder, so a render prunes only its own format’s older files); otherwise a render job is queued and the SPA polls the job. The cache needs no database state: readiness is an existence check.GET /projects/{id}/exportslists the sizes and rates a project offers (withsource_resolutionandsource_fps).- Size and rate. A short side (2160, 1080, 720) and a frame rate (30 or 60, the cap),
either of which may be above the source’s. Both default to
"original", the video’s own, which is what an API client that names nothing gets; the editors never show that word, they list the values smallest first with the video’s own named by its number. A frame rate above the source’s repeats the picture’s frames, but the captions are drawn at every output frame, so their animation is smoother.resolve_render_inputsalone turns options into the output’s size and rate, for every caller. - Green screen.
green_screendraws the captions over solid chroma green instead of the picture, with no sound, to key out in an editor. It is part of the hash, and the engine does not use the video at all. - No quality choice. A download is a second encoding of the source, so each format is
made as good as its codec does well (a CRF in
render_formats.json; ProRes takes a profile). The size is chosen with the resolution and frame rate. - The web editor has one Download button that opens a dialog (format, size, frame rate, background), as the iOS Save sheet does.
- Size and rate. A short side (2160, 1080, 720) and a frame rate (30 or 60, the cap),
either of which may be above the source’s. Both default to
- Download.
GET /projects/{id}/download/{format}?resolution=…&frame_rate=…&green_screen=…. Subtitles are not rendered: the API asks the engine (POST /subtitles, behind the same token) for SRT and VTT, whose cues are the caption lines (edit::lines) with the caption offset applied (engine/src/subtitles.rs, alsooc_subtitlesfor the apps), and JSON is the transcript as stored, without its loudness.
The caption engine
Section titled “The caption engine”apps/engine is one Rust library (rustybuzz shaping, tiny-skia drawing) with three builds: natively, linked into
the render server; to WebAssembly, drawing the editor preview over the HTML <video>; and as a static library for
the iOS app.
The preview is the export. It is the same code with the same font files, and its arithmetic is deterministic (an integer blur, no platform maths), so every build produces byte-identical frames. Nothing else may draw captions. The engine also owns the caption edits (cutting lines, retiming, editing a word, a word’s look), the subtitle files, and the render server.
Everything about it is on its own page: scenes and lines, the forty-four animations, word looks, fonts, colour, the C ABI and the render server.
The editor
Section titled “The editor”The page is the preview beside the style panel, with the timeline docked
full-width underneath; on a narrow screen the same pieces stack. One layout is
mounted at a time, so there is one <video> and one engine whatever the width.
- Preview. The video with the engine’s frame drawn over it, fitted to its
panel. While paused, the caption block can be dragged (it sets
position_x/y) and a word double-clicked to edit: spaces inside it stay (it is still one word), an empty edit deletes it. A tap on the picture plays or pauses. - Timeline. A ruler over a video track and a caption track, with the
playhead across them. Caption blocks are the engine’s
lines; a selected block’s edges retime through the engine (a caption that touches its neighbour pushes the neighbour’s edge along, down to a minimum). Blocks are flat clips with a hairline between them, so a zoomed-out timeline never turns them into overlapping bubbles. The ruler and both tracks seek by click or drag. Ctrl/Cmd + wheel or a pinch zooms around the pointer, the buttons around the playhead, and Fit shows the whole video. - Transport. Play/pause, the timecode and mute; Space plays, the arrows step a frame.
- Undo and redo. Buttons beside the zoom, Ctrl/Cmd+Z and Shift+Ctrl/Cmd+Z. As on
the phone, each step puts back a snapshot of the transcript, the style and the
offset (
lib/history.ts, held by the editor store), and a run of one kind of change (a slider, an edge drag) made close together is one step. Loading the project starts the history afresh. - Edit as text. A dialog with the transcript as JSON, a word to a line, for what
the controls do not do yet (splitting or merging segments, retiming many words).
Applying checks it (
lib/transcriptText.ts, which names the segment and word that are wrong) and replaces the transcript as one undo step. The same dialog imports a subtitle file (SRT, WebVTT with or without per-word times, or our JSON): it is turned into the same text first, to look over before it is applied. - Playback. The one
<video>is shared through a context. Its playing time never passes through React state: the timeline, playhead and timecode follow the element each frame and write to the DOM directly. - Autosave. Edits are saved 800 ms after the last one; there is no Save button.
- Style panel. In tabs (Presets, Text, Background, Animation, Outline, Timing) so that no page is long, on iOS and the web alike. The preset tiles are a grid that fills the width and wraps.
Look. The web app and the iOS app share one look (apps/web/src/index.css holds the web’s
tokens, Theme the iOS app’s): a white or near-black page, a surface for cards, a stronger one for
controls, the caption highlight yellow as the single accent (a deeper gold where it is text on
white), rounded corners, and the “burned-in subtitle” wordmark. It is light or dark and follows the
system until the user chooses. Projects are a grid of poster cards; in the timeline the selected
caption is yellow and the playhead is the page’s ink colour.
Transcription
Section titled “Transcription”The web app and the iPhone app both ask in two steps: where to transcribe and with which model, then
the spoken language, from a searchable list with a flag for each that follows the model (the API says
which languages a model takes: ModelOption.languages, null for Whisper, which takes any). There is no
“detect it” choice in either app: a language is always chosen, starting from the last one used, else the
device’s or the browser’s. The API still accepts auto for its other clients.
A provider seam (app/transcription/) takes audio and returns a Transcript:
-
local: a model on this machine, run by the engine its entry inapp/services/asr_models.pynames. Models download on first use intomodels/.- faster-whisper (CPU or CUDA) runs the Whisper sizes. The list offers Small and Large v3 (the Turbo
build), the phone’s; another listed Whisper size runs when an API client names it (any other name is refused with
unknown_model: faster-whisper would fetch arepo/namefrom Hugging Face), as doesDEFAULT_MODEL, which (Parakeet Ultra) is what a request that names none gets. Everything is decoded: the voice-detection filter is off, because it takes shouting and speech over loud music for non-speech and what it drops is never transcribed. The no-speech check and a hallucination guard stay on. faster-whisper still moves on from a window when the model says “no speech after here”, leaving some loud stretches empty. The server does not read them a second time (the phone does): it costs several times the transcription time for a few words (measurements); a model that does not do this, Parakeet Ultra, is the default. - sherpa-onnx (ONNX Runtime, CPU) runs the other models; Parakeet Ultra is the first. It
cuts the audio into windows at the quietest point (
chunking.py), never skipping a stretch for being “not speech”, and decodes a window again in halves when it comes back empty though it is not quiet. A model that covers only some languages is never given another: the language is identified first (language_id.py) when it was not chosen, and a recording outside the model’s languages is refused, naming the language (LanguageNotCoveredError).
Parakeet Ultra is fetched from
leogaudin/sherpa-onnx-nemo-parakeet-ultra-int8at a pinned commit (AsrModelInfo.revision), built byscripts/asr-bench/export_ultra.py.Adding a model is adding an entry there (and an engine, if it needs one); nothing above the provider seam changes. How the choices were made, with measurements, is in the speech model benchmarks.
- faster-whisper (CPU or CUDA) runs the Whisper sizes. The list offers Small and Large v3 (the Turbo
build), the phone’s; another listed Whisper size runs when an API client names it (any other name is refused with
-
openai: the OpenAI API. Audio leaves the machine, so the UI says so whenever this provider is active. -
opencaptions: another OpenCaptions backend, reached through its transcription API (below).TRANSCRIPTION_REMOTE_URLandTRANSCRIPTION_REMOTE_KEYname it; the audio leaves the machine, so the UI names its host. A laptop stack without a GPU can hand its transcriptions to one that has.
The provider and model are chosen per job, with the deployment’s defaults preselected. The seam doesn’t depend on the model, so any engine that yields words with timings fits behind it.
A job moves through named stages, each stored on the job as well as broadcast, since a
page opened mid-job reads the database: loading (or first downloading) the model, then
transcribing, whose progress is written down every couple of seconds. Whatever the
provider returns has its segments ended at a pause (app/transcription/words.py, the same
tempo-relative rule as the captions’), because with voice detection on (or a model that
decodes in windows) a segment can hold words from either side of a long silence.
The transcription API
Section titled “The transcription API”What any OpenCaptions component calls to have speech transcribed on a backend, with no
project in between (app/api/transcriptions.py). The result is the Transcript every
part of the system already uses, so a caller maps nothing: the iOS app and an instance
with the opencaptions provider are two clients of it. Auth is an API key
(Authorization: Bearer oc_…), minted on the Account page, which also makes a
opencaptions://connect?url=…&key=… link that sets the phone app up.
| Call | |
|---|---|
GET /api/v1/transcription/capabilities | api_version, the instance’s name, models, languages, limits, retention. A client refuses a version it does not know. |
POST /api/v1/transcriptions | audio (anything ffmpeg reads) + language [+ model]; returns 202 {job_id} |
GET /api/v1/jobs/{id} | progress, as for any job |
GET /api/v1/transcriptions/{id} | the Transcript, once completed (409 before, 404 after it expires) |
DELETE /api/v1/transcriptions/{id} | cancel and delete everything of it |
It is asynchronous because a long recording takes minutes on a CPU. The audio is deleted
when its job ends; the result is kept TRANSCRIPTION_RESULT_TTL_H (24) hours so a client
that was suspended can still fetch it, and the first request after that time removes what
has expired, so no separate janitor runs. Deleting a job (a phone does, as soon as it has the
transcript) removes its audio and transcript; a job that did work stays as a row with the status
deleted, because the account’s usage is summed from those rows. A user may have TRANSCRIPTION_MAX_CONCURRENT
(2) running. A job has its own owner (jobs.user_id), so it needs no project. The
opencaptions provider sends an X-OpenCaptions-Hop header, and an instance that itself
forwards refuses a request carrying it, so two instances cannot be configured into a loop.
The remote address goes through the same SSRF guard as video_url; SSRF_ALLOWED_HOSTS
admits a GPU box on the LAN. Sample responses in the iOS package’s test fixtures are read by both the API tests and the
app’s tests, so neither end can change the contract alone.
Languages
Section titled “Languages”The interface is in English, French, Spanish, German, Polish, Portuguese (Brazil), Italian, Russian, Turkish, Japanese, Korean, Simplified Chinese and Indonesian. The browser’s or the phone’s language is used; the web also has a choice on the Account page and on the sign-in screens.
- Web. The English text in the code is the key:
t("Download"), with{name}for values, andlocales/<code>.jsonholds the others (lib/i18n.ts, which loads only the language in use, before the first paint). A text without a translation shows in English. - iOS. SwiftUI text and
String(localized:)are collected in the app’s string catalogs (Localizable.xcstrings,InfoPlist.xcstrings), and the Kit has its own for the words it produces (errors, what a long job says). - Tests fail on a text missing in any language or a translation that loses a placeholder
(
i18n.spec.ts,LocalizationTests). What the server says (its errors, a job’s progress) is not translated, and neither is the watermark.
Captions in other scripts. The engine shapes each word with its own direction and script,
lays a right-to-left line (Hebrew, Arabic) out from the right, and falls back to the bundled Noto
Sans faces for Arabic, Hebrew, Devanagari and Thai. Chinese, Japanese, Korean and the other Asian
scripts need fonts too large to bundle, so the engine says which families a transcript needs
(scripts.rs, oc_fallback_fonts: Han is drawn in the Japanese, Korean or Chinese face by the
kana, hangul or language) and the host fetches them from Google Fonts as it does a style’s own
font, naming them in the scene’s fallback_fonts. The render server works the families out itself
(Transcript::fallback_families) and reads each from the API (GET /jobs/{id}/fonts/{family}, authorised by the job’s token
the engine already holds for progress; a font it cannot read is left out), so no host has a copy of the rule; its cases are
testdata/script_fonts.json. Adding a language means its code in the list and a column of translations.
The browser does not fetch the four bundled script faces with the engine (about 1.8 MB of the 3 MB
of fonts): fonts.json lists them apart (the files named NotoSans*, which scripts.rs holds to
its own table), and oc_script_fonts says which a transcript needs. loadFallbackFonts fetches
those, when the words have letters of the script, and registers each with oc_add_font_at at its
rank among the font files, so the faces are tried in the order of their names whenever they came
and a frame is the one the render server draws. An edit that brings a new script goes through the
same call, and the scene is laid out again once the face is in. The phone and the server have all
the files and register them in order.
The browser’s engine build is the release build. Measured, with the module at 1.39 MB (489 KB
sent): opt-level = "s" sends 7% less and draws a heavy blurred frame 55% slower (60 to 92 ms in
Node); panic = "abort" changes nothing (the target never unwinds); wasm-opt (binaryen 133)
takes 7% to 14% off the file and 1% off what is sent. None is worth its cost.
- Postgres:
users,projects(transcript and style as JSON, video metadata, timing offset),jobs(the owner, type, status, progress, message), andapi_keys(hashed). A project stores no state of its own: the project list reads what it is doing (draft, transcribing, transcribed, failed) from its transcript and its transcription jobs, and a render’s progress and failure are its job’s. - Object store: everything under
projects/{id}/, plusfonts/. Deleting a project deletes its prefix. - Types: Pydantic models in
apps/apiare the single source of truth.api.generated.tsis generated from the OpenAPI schema and committed, and CI fails if it drifts. The built-in style presets are data (apps/web/src/lib/presets.json), read by the web and bundled by the iOS app; a test keeps them validStyleConfigs and the first one equal to the API’s default.
Accounts and security
Section titled “Accounts and security”- Sign-in. Email and password, with an httpOnly session cookie plus a CSRF token. Password reset works over SMTP when it is configured. Auth attempts are throttled per account and per source address.
- API keys. Bearer keys for scripts and the same API the SPA uses. Managing keys and sessions needs a browser session.
- Isolation. Every project and job route resolves through an ownership check.
- Exposure. Only
webis published. It binds0.0.0.0, so phones on the same network can use it; put it behind a reverse proxy to expose it further.
Configuration
Section titled “Configuration”There is no env file. app/core/config.py holds the defaults for this topology,
so the stack boots with no configuration at all. docker-compose.yml, the one
compose file, names only what a container can’t infer: shared credentials,
service hosts, and per-service overrides. A setting is added to the
x-oc-env block, which the API and both kinds of worker share. check-compose.sh keeps every
copy of a shared value equal to the others and to config.py.
HOSTED_MODE is the one switch between running it for yourself and running it
for others. When it is on, the API withholds host details (health, models, device)
and refuses per-job provider or model choices. The SPA only reflects what the API
returns. An entitlement seam (services/entitlements.py) is where per-user
limits would plug in.
Apple apps (iPhone, iPad, Mac)
Section titled “Apple apps (iPhone, iPad, Mac)”apps/ios. Everything runs on the device: no server and no accounts (a server is an option, below).
It is a SwiftUI app over three things it does not reimplement. The iPhone, iPad and Mac apps are one
multiplatform target (supportedDestinations: [iOS, macOS]) with one bundle id, so they are one App
Store record, and one purchase of Pro (a StoreKit entitlement, with no account or server) covers all
three: universal purchase. Below, “iOS” is the iPhone and iPad; the Mac is described at the end of the
section.
| Piece | iOS |
|---|---|
| Caption drawing and edits | The same engine crate, as a static library in OpenCaptionsEngine.xcframework (device, Apple-silicon simulator, macOS: apps/engine/scripts/build-apple.sh). Swift imports the C header through a module map. Only the oc_* functions leave the library (build-apple.sh makes the rest private), since FluidAudio’s own Rust library is linked beside it and a name in both stops the linker. One Swift actor, CaptionEngine, makes every call: the engine’s fonts are one book per process and a scene is a handle; it allows its calls from any thread if they are serialized, which an actor guarantees. |
| Transcription | WhisperKit and FluidAudio (Parakeet) (Core ML, Neural Engine), pinned, in their own SwiftPM target so the core tests do not build them; iOS 26’s SpeechTranscriber beside them. Its result is mapped to the same Transcript shape the way the server’s local provider does, so transcripts are interchangeable. A Transcriber protocol sits in front, so a hosted endpoint can be a second conformance later. |
| Decode, composite, encode | AVAssetReader decodes, the engine draws each overlay, Core Image composites, AVAssetWriter encodes (H.264, or 10-bit HEVC for HDR) with the audio re-encoded as AAC. The picture is baked upright at the size it is shown. |
Layout
Section titled “Layout”project.yml (XcodeGen; the .xcodeproj is generated, not committed) describes the app target,
which is SwiftUI views and wiring. Everything testable lives in the local package
OpenCaptionsKit: models in the API’s shapes, the engine actor, project storage, the editor’s
logic, the exporter. The minimum is iOS 18, for the app’s scroll and gesture APIs. The app is
universal (iPhone and iPad); the iPhone stays in portrait, as the layout is not drawn for
landscape. iOS is not part of make ci: it has its own macOS workflow, and nobody without a Mac
is blocked.
The look is plain SwiftUI with no UI library: Theme holds the handful of colours (each a light
and a dark value), the button styles, the card and the wordmark, and the screens draw their own top
bars instead of the system navigation bar (the edge swipe back is put back by hand). Sheets (style,
transcribe, save) use the same surfaces.
The editor
Section titled “The editor”It mirrors the web one.
- Preview. An
AVPlayerwith the engine’s frame on a layer above it, redrawn on the player’s clock. A tap plays or pauses. While paused, a drag moves the caption (snapping to the video’s centre lines with a guide and a haptic tick, by the engine’s rule), a double-tap opens a card to edit one word (the keyboard opens with the word selected; spaces inside stay, it is still one word), and two fingers pinch the font size. - Dragging. The grab region is the caption’s box made at least 48 pt across and 24 pt wider
all round (
CaptionGestures.dragRegion), measured from where the finger landed (a pan is only recognised after it has moved a little), and it works while the video plays. - Timeline. A ruler over a video track and a caption track, with edge handles that retime through the engine. The playhead stays in the middle and the timeline moves under it (the track is offset by the playing time, so only a small modifier and the ruler read it, never the tracks). A finger dragging anywhere on it scrubs, pausing a playing video, and coasts a little on release; a pinch zooms; a tap seeks. It opens at 80 pt per second. Dragging a caption’s edge holds the track still, or it would move under the finger.
- Transport and undo. Play, the time (current over total), mute, undo and redo.
EditorModelrecords a snapshot (transcript, style, offset) before each change, and a run of one kind of change (a slider, an edge) is one step. - Layout. The video takes the screen, with only the compact timeline under it. On a wide
screen the style controls sit beside the video; on a phone they come up over it as a sheet that
stops a little over half the screen, low enough to keep the caption in view. Style controls and
presets are the web’s, from the same
presets.json; the caption offset is the engine’s. - Autosave after a quiet moment and when the app leaves the foreground; there is no Save button.
- Importing. A picked video is copied somewhere the app owns and then shown (a poster, a name that can be changed, its size and length) before it is imported; cancelling throws the copy away.
Storage
Section titled “Storage”Projects are files, because one process reads and writes them: Application Support/Projects/<id>/
holds:
project.json: title, dates,Transcript,StyleConfigand timing offset, in the API’s shapes, so a project moves between phone and server unchanged;source.<ext>: copied in at import, so a project survives the clip being deleted from Photos;renders/: cached videos named by a hash of what decides their pixels (local to the phone, not the server’s hash), excluded from backup.
Writes are atomic (a temporary file, then a rename). The project list is a scan of the folder, and
an unreadable project is hidden rather than failing the list. Subtitle files (SRT, VTT) are
written by the engine, as the server’s are (oc_subtitles), and shared from the Save sheet. Fonts are the same as the server’s: Inter, Poppins, Montserrat and Nimbus Roman
are bundled with the engine’s other fonts, in the same order the server loads them, and a style that
names another Google Fonts family fetches it once (TrueType, the weight nearest 800) and keeps it on
disk.
Speech models
Section titled “Speech models”- The list. The Whisper sizes WhisperKit publishes (Whisper Small and Large v3, the 627 MB build; no
English-only or superseded ones, and no second, slower Large v3), Parakeet Ultra and Parakeet Redux (FluidAudio, Core ML: faster, 25 European
languages, offered only for those; Redux is the small download and does worse in noise), and on iOS 26 Apple’s own
SpeechTranscriber(built in, nothing to download, a language must be chosen). Each model names the engine that runs it (SpeechModel.engine) andLocalTranscriberroutes to it; adding a model is listing it. The reasons, with measurements, are in the speech model benchmarks. - Downloads. On demand, into a backup-excluded folder, never bundled. The default is Parakeet
Ultra, and the model chosen last is the one offered next (
transcribeModel). A Parakeet download fetches the files only (ModelHub.download): FluidAudio’s ownAsrModels.downloadalso compiles each model, minutes with nothing to show, so that is left to the first load, which says what it is doing. A metered connection asks before a download. - Loading a model into memory is the longest wait: the first load, Core ML builds the model’s Neural Engine plan for that chip (about 30 s for Parakeet Ultra’s encoder on an M1 Mac with 8 GB, minutes on an iPhone 14 for the Turbo model), and the system keeps the result, so later loads take seconds (the same Mac: 2.8 s). The cache belongs to the build of the app and to the OS: a new build of the app, or an update of the OS, pays it again. That is every rebuild during development, so time a load on the second launch of one build, never the first, and a user pays it once after installing or updating. The screen says “Optimizing for this device…” and that later transcriptions are much faster (not “loading”, and not “the first time”, which is wrong after an update). Loading starts early and beside the reading of the audio: the default model as the app opens (when it is downloaded), any other as soon as it is chosen in the Transcribe sheet, while the language is picked. The loaded model stays for the next transcription and is let go on a memory warning or when the app leaves the screen.
- Missed speech (shown as “Second pass (n of m)…”). Whisper skips a whole 30 s window it
judges silent, which music and noisy speech trigger, leaving a hole in the captions with good ones
on either side. After the main pass, every stretch of 6 s or more without words that is not quiet
(at most 12) is decoded twice without that judgement, the second window shifted, and only the
words both readings give are kept (
TranscriptGaps; text invented over music differs between the two). The server tried it and does not keep it (see the benchmarks). - On a server. Settings → “Where to transcribe” switches between this phone and “My server”:
another OpenCaptions backend, connected by pasting the link the web app makes (or typing the
address and key) and checked before it is kept. The key is in the Keychain, the address in
preferences.
ServerTranscriberis aTranscriberlike the on-device one: it exports only the audio (AAC, about 1 MB a minute), uploads it, follows the job, fetches theTranscriptand tells the server to forget it. The transcribe sheet then lists the server’s models and downloads nothing. A pairing link opened on the phone asks before it is used, because it decides where the audio goes. The upload and the wait need the app open; plainhttpis allowed only to local-network addresses.
Settings
Section titled “Settings”A second tab holds the appearance (system, light or dark), the default spoken language, the speech
models (each can be downloaded or deleted, with its size on disk), what the app stores (with a button
to clear the cached videos, which can be made again), and about, including a button that shares
diagnostics.log: a small log kept on the device with the milestones of the long jobs and any
uncaught exception, so a crash that leaves no report can still be explained.
Saving
Section titled “Saving”Save opens a sheet first:
- Format: H.264, which plays everywhere, or HEVC, about a third smaller.
- Size: absolute values, smallest first (720p, 1080p and 4K by the short side), with the video’s own size among them named by its pixels. Larger than the source too: a 144p video can be saved at 4K, the picture scaled up and the captions drawn sharp at the size saved.
- Frame rate: 30, 60 and the source’s own, each by its number. A lower one keeps evenly spaced frames; a higher one repeats them while the captions are drawn at each, so they animate smoother.
- HDR source: whether it stays HDR (10-bit HEVC) or is tone-mapped to an ordinary SDR video before the captions go on.
- Background: the video, or a green screen (only the captions over solid green, always SDR, for an editor to key out). It is not remembered, so a later save is not captions-only by surprise.
The other choices are remembered. An estimate of the size is shown (from bits per pixel, with HEVC
needing two thirds of H.264’s; there is no quality choice, a saved video is made as good as it can
be), and when it would not fit in the free space Save is disabled with a message saying so.
Everything the options decide is part of the file’s name (ExportKey).
HDR. A PQ or HLG source stays HDR: decoded to 10 bits, written as 10-bit HEVC with BT.2020. Core
Image puts sRGB white well above reference white in an HDR signal, so the captions are scaled by a
measured factor per transfer function, and the tests read the output’s luma to check where they
land. A saved video’s captions land at five times reference white (about 1000 nits in PQ, the top of
the range in HLG): real footage has its walls and skies at about one and a half times reference
white, so captions at twice it were no brighter than the wall behind them and read as dim. The
preview draws an HDR video’s captions on a half-float, extended-range layer at four times
(CaptionFrame.hdrWhiteScale): that layer shows brighter than the player shows the file, so the two
factors differ to look the same.
Free and Pro
Section titled “Free and Pro”Entitlements (in the Kit) is the one place the tier’s limits are written. A free app:
- puts a small watermark on the picture and the saved video. The engine draws it (
watermarkin the scene), so the preview and the save carry the same one, and it is part of the saved file’s name. The iOS preview asks the engine where it is (oc_watermark_rect) and keeps it on a layer of its own, so dragging or pinching a caption never moves it; - saves at up to 1080p and 30 fps, and turns an HDR video into an ordinary one;
- locks the styles marked
"pro": trueinpresets.json(the web ignores the flag).
The screens lock what the tier lacks and show ProSheet; the save also passes its options through
Entitlements.limit, so a remembered choice cannot get past a screen. Nothing else is gated: the
engine and the rest are open source. A build from source is Pro; an App Store build (compiled with
APPSTORE) starts free until a purchase says otherwise. Pro is a one-time purchase
(Purchases.swift, StoreKit 2, only in an App Store build; Config/Pro.storekit is the test
configuration the scheme runs with, so a purchase can be tried in Xcode with a test price), and the
Pro sheet shows the store’s price. A debug build picks the tier in Settings or with
OC_TIER=free|pro, and shows a test price.
The Mac app
Section titled “The Mac app”The same target built for macOS 15 (Apple silicon: the engine’s macOS slice is arm64). Nearly all of the app is shared; what differs is small and lives in a few places:
- The preview.
PreviewCore(Views/PreviewCore.swift) holds the drawing (the player’s layer, the engine’s picture over it, the watermark’s mask, the centre guides) and the live drag and pinch, and has no#if: a host gives it a layer and its size and turns its own input into intents (tap,doubleTap, the drag’s and the pinch’s), and every calculation is stillCaptionGestures’s.PreviewUIView(touch recognisers) is the iPhone’s host andPreviewNSView(click, double click, pan and the trackpad’s magnification recognisers) the Mac’s. A Mac layer has its origin at the bottom, so the core is told it isflipped: it lays its layers out from the top inside a container that is turned over, each turned back so its picture is upright (the masks, the live transforms and the drawing were checked to behave as on iOS). - Platform shims, all in
Platform.swift, so the views carry almost no#if: keeping the machine awake (KeepAwake: the idle timer, orProcessInfo.beginActivity), the clipboard, the haptic tick (a Force Touch trackpad’s), the modifiers for iPhone-only chrome (navigation bar, tab bar, status bar, keyboard type), the sentences that name a phone or a Mac (ThisDevice), and the save panel (SaveDialog). - The window. One window with the projects (Settings is its own window, ⌘,), a minimum size, and menus:
File gains Import Video… (⌘O) and Export… (⌘E), and a Playback menu has Play/Pause. A menu acts on the window
in front, so each screen publishes what it can do as a focused value (
AppCommands.swift); the Space bar is a key press on the editor and not a menu shortcut, since a menu shortcut would take the space typed into a text field. - Import has three entries that meet in one path: the Photos picker, a file chosen in the system’s panel, and a file dropped on the window. A file is copied into the app’s own temporary folder (a sandboxed app opens a chosen file for as long as it is asked for) and then imported as a picked video is.
- Saving offers Save… first (the save panel, named after the project, which also grants the sandbox the right to write there), then Share and Photos.
- No background jobs.
BackgroundJobis the phone’s; the Mac keeps the machine awake instead, and a save carries on whether or not the window is in front. - Release.
make mac-build,make mac-archiveandmake mac-upload(with the same API key as the iPhone’s) build, archive and send it to TestFlight for the same app record. The sandbox entitlements (Config/OpenCaptions-macOS.entitlements) are the user-selected files, the network and Photos.
Long jobs
Section titled “Long jobs”The app keeps the screen awake during a download, a transcription or a save. On iOS 26 a save the user started
goes on when they leave the app: BackgroundJob (the Kit) submits a
BGContinuedProcessingTaskRequest as the job begins, under an identifier permitted in the Info.plist by its
prefix (org.leogaudin.opencaptions.job.*, one fresh suffix per job), reports the job’s fraction to the task’s
Progress, and ends it with the job. The system draws the card on the lock screen and in the Dynamic Island,
and its cancel button, or the system running short of time or memory, reaches the job as onStop. Where it
is refused, or before iOS 26, the job is inert and works as it always has: the sheet asks the user to keep the
app open, and a save is stopped with a message when the app leaves the screen, since the system takes the
hardware encoder away from an app that is not in front. ExportController.continuesInBackground is what
tells the screen not to stop a save that the system is keeping alive. A transcription is not one of these jobs:
the speech models run on the Neural Engine, which the system takes from an app that is not in front (FluidAudio
then fails with “AsrManager not initialized”), so it needs the app on the screen. Editor models belong to the app, not to
a screen, so a transcription or an autosave in progress carries on when the user goes back to the
project list, where the project’s row shows its progress.
Agents and the command line
Section titled “Agents and the command line”apps/agent is the opencaptions npm package: an MCP server over stdio (opencaptions mcp) for Claude Code,
Claude Desktop, Cursor and other clients, and a command line (opencaptions caption) for scripts. The same
actions (src/captioner.ts) run in one of two places:
-
On a server, when
OPENCAPTIONS_KEY(orOPENCAPTIONS_URL) is set: it is a client of the HTTP API and nothing more. It uploads a video with an API key, starts the transcription, sets the style, and asks for the download (src/captions.ts). -
On the computer otherwise (
src/local/). Parakeet Ultra, the server’s default model at the same pinned revision, runs throughsherpa-onnx-node; the audio is cut into windows and the model’s pieces made into words as the server does it, held to the sharedFixtures/token-words.json. The engine’s WebAssembly draws each frame’s caption band, and FFmpeg runs the command the engine’sencode::planmakes, the render server’s own, so a file comes out as the server makes it. The size and frame rate are decided as the API decides them, the formats arerender_formats.json, and the look’s font is fetched from Google Fonts as the API fetches it. A project is a file beside the video,<name>.opencaptions.json, and its path is the project id. -
Types. Its calls go through
openapi-fetchover a copy of the generated types, and its tools take the style and the save options as the API’s own JSON schemas (src/generated/).scripts/generate-api-types.shwrites them with the web’s types, with the built-in looks, andmake typegen-checkfails on a stale copy. The style’s descriptions inschemas.pyare what an agent reads, in the tool and fromdescribe_style. -
Edits. Fixing a word and dealing a look’s word variants are the engine’s (
edit.rs), through the same WebAssembly file the editor loads, built into the package bymake agent-engine. -
Long jobs. On a server, a tool waits up to 45 seconds (
OPENCAPTIONS_WAIT_SECONDS), sending MCP progress, then hands back a ticket holding the project, the job and where the file goes;check_progresscarries on from it. Nothing is kept between calls. -
Out. A tag publishes it to npm with provenance and lists it in the MCP Registry (
server.json, whose name the package’smcpNamematches). The Claude Code plugin (apps/agent/plugin, listed by.claude-plugin/marketplace.json) runs it withnpxand adds a skill on when to use it. The Claude Desktop extension (apps/agent/mcpb, built byscripts/build-mcpb.sh) is the package, its production dependencies and both Mac architectures’ speech engine in one.mcpbfile; a tag’s CI attaches it to a draft GitHub Release, andmake test-agent-mcpbstarts a bundle and lists its tools.
The documentation site
Section titled “The documentation site”The documentation is plain Markdown in docs/, so GitHub shows it as it is, and apps/docs builds the same
files into a static site with Starlight (it lives at docs.opencaptions.app).
The site owns no content. Its sidebar is generated from the folders (apps/docs/astro.config.ts names a folder’s
group, a page’s sidebar.order frontmatter orders it), so a new page needs no entry anywhere; a new folder needs
one group.
- A page is plain Markdown that GitHub shows as it is: it starts with its own
# Title, and links another page with a relative.mdlink.apps/docs/plugins/remark-docs.tsturns those into what the site needs (the page’s URL; the title drawn by the theme). Links to the code are absolute GitHub URLs. A broken link or anchor fails the build (starlight-links-validator, and the plugin for a link to a missing file). - Search is Pagefind: an index built with the site and searched in the browser, so no service and no query
leaves the page. The site sends no telemetry (
ASTRO_TELEMETRY_DISABLEDin the Dockerfile). apps/docs/Dockerfilebuilds it in a container, with the pages as a named context (--build-context docs=docs, copied tosrc/content/docs, where Starlight reads them), and itsdocs-sitestage holds only the static files. ThedocsCI job andmake cirun that build,make docs-buildwrites it toapps/docs/dist, andmake docsserves it with live reload.- It is deployed as static files, like the demo:
publish-docsdeploys thedocs-siteartifact withwrangler deploy(apps/docs/wrangler.jsonc, a Worker namedopencaptions-docs, a 404 page) onmain, only whenCLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_IDare set. The domain is attached to the Worker in the Cloudflare dashboard.
The public demo
Section titled “The public demo”apps/web has a second entry, demo.html (src/demo/, built with vite.demo.config.ts), that is
the site at opencaptions.app: static files for a Cloudflare Worker (static assets), no API, no account. It is the
editor’s own CaptionPreview and PresetStrip over one sample clip (it loops), so the captions are drawn by
the same engine (WebAssembly) as in the editor and the download; nothing is drawn twice.
src/lib/sources.tsis the seam: where the preview reads a project’s video and a font family. The application’s default is its API; the demo points them atdemo-public/demo/{clips,fonts}.disableSaving()in the editor store keeps edits in the page.- The clips are data:
demo-public/demo/clips.jsonnames each clip’s video, transcript (the API’sTranscriptshape) and credit (shown in the footer; CC BY asks for it).scripts/make-demo-clip.shcuts one from a long film (9:16 crop, H.264 + AAC; the current one is 720x1280, 14 s, about 1.4 MB, small enough to serve from the site itself). Safari plays a video only from a server that answers Range requests, and Cloudflare’s static assets answer them with the whole file, so the clips go through a Worker (apps/web/demo-worker.ts,run_worker_firstfor/demo/clips/*inapps/web/wrangler.jsonc) that returns the bytes asked for (206). Replacing a clip is replacing its files and the manifest entry; with more than one, the page shows a chip for each. - The engine’s
.wasmand fonts are not committed: the web Dockerfile’sdemo-sitestage builds them and the site (make demowritesapps/web/dist-demo). CI builds that stage on every run andpublish-demodeploys it withwrangler deployfromapps/web(wrangler.jsonc) onmain, only whenCLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_IDare set (the Worker is namedopencaptions). - The page is found by what it says, without running script:
src/demo/Landing.tsxholds its words and has no browser-only code, so the build renders it to HTML (scripts/demo-prerender.ts, a plugin invite.demo.config.ts) and React replaces it when the demo is ready.src/demo/seo.tsis the one place for the title, description, cards, icons and structured data (written into<head>atdemo.html’s<!--seo-head-->); its FAQ (src/demo/faq.ts) is the text shown on the page. The page exists in every language of the interface: English at/, the others at/<code>/(src/demo/pages.ts), each prerendered in its language with its own title, description, canonical address andhreflanglinks to all the others; the footer links them as plain anchors. The address names the language: a visitor at/whose browser (or saved choice) is another language is sent to that page, and one who picked English stays. A new language is a newlocales/<code>.jsonplus its entries inpages.tsandsitemap.xml; the tests fail until all agree. Files for crawlers are indemo-public/:robots.txt(everyone welcome, the AI crawlers named),sitemap.xml,llms.txt, the icons andsite.webmanifest, andog.png(the link preview, rebuilt byscripts/make-og-image.swift).tests/unit/demo-seo.test.tschecks all of it. When the App Store link exists, setAPP_STORE_URLinlinks.ts(the page and the structured data follow) and updatellms.txt. - The fonts in
demo-public/demo/fontsare the families the presets use (OFL), fetched once byapps/web/scripts/fetch-demo-fonts.mjs; a family missing there is drawn in the default face. - It offers presets only: no upload, no export, no Pro or account feature exists in it to abuse.
npm run dev:demoputs the engine assets indemo-public/enginefirst (scripts/demo-engine.sh: cargo, else Docker).
Licence
Section titled “Licence”AGPL-3.0-only: anyone may self-host or modify it, and a hosted fork must publish its changes. Contributors accept the CLA, which lets the maintainer also ship their code where the AGPL can’t go, such as the App Store.