catalogue / tools / Audio & video / Ogg to SRT

Convert Ogg to SRT (subtitle track)

To convert Ogg to SRT (subtitle track), send one POST to /v1/subtitle-extract with the Ogg source and "to": "srt" in the body. "srt" is the schema default of "to", so the field may also be left out. Each call costs $0.003 in USDC on Base via x402, with no account and no API key. The source file can be up to 200 MB.

Endpoint
POST /v1/subtitle-extract
Price
$0.003 per call

01Limits

LimitValue
Largest source file200 MB (209,715,200 bytes)
Timeout60 s
Source formatsAVI, MKV, MP4, Ogg
Output formatsSRT, WebVTT
Option streamdefault 0

02Example

A real Ogg to SRT run of subtitle-extract.

Request
POST /v1/subtitle-extract
content-type: application/json
payment-signature: <base64 x402 payload>

{
  "url": "https://grist.tools/samples/av/pair-clip.ogg",
  "stream": 0,
  "to": "srt"
}
Response
200 OK
payment-response: <base64 settlement receipt>

{
  "source_url": "https://grist.tools/samples/av/pair-clip.ogg",
  "bytes": 12553,
  "container": "ogg",
  "stream_index": 0,
  "format": "srt",
  "cue_count": 2,
  "subtitle": "1\n00:00:00,000 --> 00:00:01,750\nRain taps on the window.\n\n2\n00:00:02,250 --> 00:00:03,750\nA lamp glows in the hall.\n\n"
}

Source file: av/pair-clip.ogg, 12.3 KB (12,553 bytes). 4 s Ogg file: a 64x36 Theora video stream at 1 fps (a slate field with a small amber square moving right) and a mono 8 kHz FLAC audio track of two 500 Hz triangle beeps, both muxed by ffmpeg, plus a two-cue OGM text subtitle stream added by the generator. The request sets stream to 0. The recorded run returned 117 bytes of SRT, 1% of the source size, with the source read as the ogg container, stream index 0 and 2 cues. Recorded with ffmpeg 8.1.2.

In the sample itself, 16 Ogg pages carry 3 logical streams: Theora 3.2.1 video of 64 by 36 pixels at 1 frame per second (serial 0), FLAC 1.0 mapping audio at 8,000 Hz with 1 channel (serial 1) and an OGM text stream (serial 2). The end-of-stream pages hold granule positions 2,250 for serial 2, 67 for serial 0 and 32,000 for serial 1. The returned text starts with cue number 1. Its 2 timing lines are 00:00:00,000 --> 00:00:01,750 and 00:00:02,250 --> 00:00:03,750, giving hours, minutes and seconds, and a comma before the milliseconds. Every cue has a number line above its timing, 1 and 2.

03Format notes

Ogg as a source

An Ogg file opens with the capture pattern OggS, and the container can carry Vorbis, Opus or Theora streams. Grist sniffs that pattern and hands Ogg to three of the conversion services on these pages. Audio conversion decodes the first audio stream, leaving any Theora picture aside. A thumbnail request seeks before opening the input and decodes a single frame from the first video stream, discarding sound. Caption extraction maps a subtitle stream counted from zero among the subtitle streams and serialises it through ffmpeg. Because audio-convert writes its Opus output inside Ogg, a file produced by that service comes back as an Ogg source, not as a separate Opus format. Theora is a lossy video codec, so a frame taken from it carries compression noise into the thumbnail, unlike a clip whose video stream is itself stored losslessly.

SRT as a target

SRT written by subtitle-convert numbers its cues sequentially from one and prints every timestamp as HH:MM:SS,mmm with a comma before the milliseconds, hours always included. When the source is WebVTT, each cue is rebuilt from its start, end and text, so cue identifiers, positioning settings and NOTE blocks do not survive. SubRip is also the default destination of subtitle-extract, which pulls a text subtitle stream out of a media container and writes it with ffmpeg's srt muxer instead of the JavaScript serialiser. That route refuses a stream that produces no text rather than returning an empty file, and it reports a cue count obtained by counting the timing arrows in the output. The two routes share the destination format but not the code that writes it. In the subtitle-convert file, each block stacks its index line, its timing line and its caption text, consecutive blocks are parted by one empty line, and one line feed closes the file.

Note: The container must carry a text subtitle track; image-based subtitles cannot be turned into text. An audio-only Ogg (Vorbis or Opus) has no subtitle track and fails with unprocessable (no_subtitle_stream).

04Errors

CodeHTTP
invalid_input400
blocked_target403
unreachable_target424
upstream_timeout424
unsupported_content_type415
too_large413
unprocessable422
internal500

When each is raised, and what it means for payment: /docs/subtitle-extract.

05Questions

What does it cost to convert Ogg to SRT?
$0.003 per call, paid in USDC on Base via x402.
How large can the Ogg file be?
Up to 200 MB (209,715,200 bytes). Past a limit the call answers too_large (413).
What happens if the conversion fails?
The tool answers with a typed JSON error from the errors table. Payment is settled only after the tool has produced its result; a call that fails inside the tool is never settled.

06Related