Skip to content

Videos

Captions

Add WebVTT or SubRip captions to an Appwrite video, use subtitle tracks embedded in the source, and set a default language for players.

6 min read

Raw

Captions are text tracks attached to a video. Players pick them up from the master manifest and let viewers switch languages. A caption comes from a file in Storage, from the caption editor in the Console, or from the source file itself. Appwrite does not transcribe speech, so to caption a video that has no track yet, upload the output of a transcription service or write the track in the caption editor.

Captions make a video usable with the sound off, accessible to deaf and hard-of-hearing viewers, and watchable in more languages. Each language is its own track, so one video can carry English, Spanish, and Japanese captions side by side.

Caption files

A caption file is a list of cues: a start time, an end time, and the text to show in between. Appwrite accepts the two most common formats.

WebVTT (.vtt) is the web standard:

Plain text
WEBVTT
00:00:01.000 --> 00:00:04.000
Welcome to the launch.
00:00:04.500 --> 00:00:08.000
Today we are shipping three things.

SubRip (.srt) numbers each cue and uses a comma before milliseconds:

Plain text
1
00:00:01,000 --> 00:00:04,000
Welcome to the launch.
2
00:00:04,500 --> 00:00:08,000
Today we are shipping three things.

Most editing tools and transcription services export one of these. Save files as UTF-8 so accents and non-Latin scripts display correctly.

Uploaded captions

Upload a WebVTT (.vtt) or SubRip (.srt) file to a Storage bucket, then attach it to the video. Appwrite converts it to WebVTT and segments it for streaming in the background. The bucket must allow these extensions. Any other file returns the video_caption_not_valid error.

  1. Open the video and select Captions.
  2. Click Upload caption.
  3. Select a Subtitle file from Storage.
  4. Choose a Language. The Name fills in from it, for example English, and you can change it.
  5. Turn on Default caption to have players show it automatically.
  6. Click Create.

Captions tab with an English caption marked as the default track
Captions tab with an English caption marked as the default track

With a server SDK:

const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
.setProject('<PROJECT_ID>')
.setKey('<API_KEY>');
const videos = new sdk.Videos(client);
const caption = await videos.createCaption({
videoId: '<VIDEO_ID>',
bucketId: '<BUCKET_ID>',
fileId: '<CAPTION_FILE_ID>',
name: 'English',
language: 'eng',
xdefault: true // optional
});

The name is what viewers see in the player's captions menu, so make it clear, such as Spanish or English (SDH). Names are up to 128 characters and allow the letters A-Z and a-z, numbers, spaces, and - . , ( ) _ '. Accented and non-Latin characters are not allowed in names, but are fine inside the caption text.

The REST API calls the default flag default. Because default is a reserved word in JavaScript and Dart, the Node.js, Deno, Dart, and web SDKs call it xdefault, and the .NET SDK calls it @default.

You can add up to 30 captions per video per hour. Past that, videos.createCaption() returns a general_rate_limit_exceeded error until the hour is up.

Embedded captions

Subtitle tracks embedded in the source container are extracted automatically during the first rendition or timeline job, usually within seconds of creating the video. They appear in the captions list marked as embedded (embedded: true), with no backing file in Storage. Each track is named after its title in the source, or its language tag if it has no title.

If the source marks a track as its default, that track becomes the video's default caption, unless the video already has one.

Only text tracks are extracted, such as SubRip, WebVTT, MP4 mov_text, and ASS/SSA. Image-based subtitles, such as PGS or VobSub tracks from Blu-ray and DVD rips, are skipped. To use those, convert them to WebVTT or SubRip and upload the result.

Extraction runs once per video. If you delete an embedded caption, it is not extracted again.

Language codes

Each caption has an ISO 639-2 three-letter language code, such as eng, spa, or heb. Where a language has two codes, use the terminology code, such as deu for German, fra for French, and zho for Chinese. Two-letter codes such as en are rejected.

Embedded tracks without a language tag show as und (undetermined).

To fix a track's language in the Console, open the caption and change Language in the editor's Settings panel. Retagging updates the name, language, or default flag without re-processing the file. Changing the file itself re-packages the track.

With a server SDK, pass only the fields you want to change. For example, to tag an embedded track that came in as und:

const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
.setProject('<PROJECT_ID>')
.setKey('<API_KEY>');
const videos = new sdk.Videos(client);
const caption = await videos.updateCaption({
videoId: '<VIDEO_ID>',
captionId: '<CAPTION_ID>',
name: 'Hebrew', // optional
language: 'heb' // optional
});

To replace the text of a track, pass a new bucketId and fileId together. List a video's tracks with videos.listCaptions({ videoId }).

Default caption

Players turn on the default caption automatically. A video has at most one default caption, so making a caption the default removes the flag from the previous one. When you upload a caption in the same language as an embedded default track, the upload takes over the default flag.

Set a default when most viewers watch with the sound off, as on social feeds, or when the spoken language differs from your audience's. Leave it off when captions are optional, so viewers who do not need them get a clean picture. Viewers can always turn captions on or off from the player.

Status

StatusConsole labelMeaning
pendingQueuedWaiting to be processed
startedProcessingConverting to WebVTT and segmenting
readyReadyListed in the master manifest
errorFailedThe file could not be processed. error says why
abortedAbortedProcessing made no progress for 12 hours and was stopped

To retry a failed caption, update it with a corrected file by passing a new bucketId and fileId, or delete it and upload again.

Caption editor

Click Create caption to write a track from scratch, or open an existing caption to change it. The editor shows the player, a list of cues, and a timeline under the picture.

Caption editor with a cue selected, the player, the cue list, and the timeline of cues
Caption editor with a cue selected, the player, the cue list, and the timeline of cues

  • Add a cue at the playhead, split a cue, or drag cues and their edges on the timeline to retime them.
  • From the Tools menu, use Shift timings to move all cues, or only the selected ones, when a track is out of sync.
  • Use Fix overlaps and Remove empty cues in the same menu to clean up a track, and filter the list to Only cues with issues.
  • Use Import to load cues From your computer or From Storage, and Export to download the track.

When you Save, the editor writes the track as a WebVTT file to the Storage bucket you choose in its settings, and the caption is re-packaged in the background. The bucket must accept .vtt files.

The editor checks every cue against common captioning guidelines. Errors block saving, and warnings are advice you can ignore:

CheckSeverity
End time is not after the start timeError
Cue has no textError
Overlaps the previous cueWarning
Ends after the video doesWarning
Reading speed above 20 characters per secondWarning
A line longer than 42 charactersWarning
More than 2 linesWarning

You can also download any track from its actions menu with Download WebVTT or Download SRT, for example to send it to a translator.

Delete a caption

Deleting a caption removes its segments and drops it from the manifest. For uploaded captions, the file stays in Storage.

You cannot delete a caption while it is processing. The request returns video_caption_in_progress, so wait for it to finish.

Was this page helpful?

Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.