Convert Ogg to Opus
To convert Ogg to Opus, send one POST to /v1/audio-convert with the Ogg source and "to": "opus" in the body. Left out, "to" falls back to its default "mp3", so a Opus request has to send it. 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 100 MB and 60 min (3,600 s) long.
- Endpoint
POST /v1/audio-convert- Price
- $0.003 per call
- Service
- audio-convert
01Limits
| Limit | Value |
|---|---|
| Largest source file | 100 MB (104,857,600 bytes) |
| Longest input | 60 min (3,600 s) |
| Timeout | 94 s |
| Source formats | AIFF, AVI, FLAC, MKV, MP3, MP4, Ogg, WAV |
| Output formats | AAC, FLAC, MP3, Opus, WAV |
02Example
A real Ogg to Opus run of audio-convert.
POST /v1/audio-convert
content-type: application/json
payment-signature: <base64 x402 payload>
{
"url": "https://grist.tools/samples/av/pair-clip.ogg",
"to": "opus"
}200 OK
payment-response: <base64 settlement receipt>
{
"source_url": "https://grist.tools/samples/av/pair-clip.ogg",
"bytes": 12553,
"source_container": "ogg",
"format": "opus",
"bitrate_kbps": null,
"sample_rate": null,
"audio_bytes": 33814,
"audio_base64": "T2dnUwACAAAAAAAAAAAAAAAAAAAAAGS5xGoBE09wdXNIZWFkAQE4AUAfAAAAAABP..."
}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 recorded run returned 33 KB (33,814 bytes) of Opus, 2.7 times the source size, with the source read as the ogg container. Decoded, the Opus in audio_base64 opens with 4F 67 67 53 00 02 00 00 00 00 00 00 (ASCII OggS). 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. In the returned Opus: the first Ogg page, flagged as the beginning of the stream, has stream serial 0 and one 19-byte packet, the OpusHead: version 1, 1 channel, a pre-skip of 312 samples, an input sample rate of 8,000 Hz and channel mapping family 0.
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.
Opus as a target
An Opus result is libopus-encoded audio inside an Ogg container: the ogg muxer writes it, and the recorded outputs begin with the OggS capture pattern followed by an OpusHead identification header. For that reason a returned Opus file is recognised as ogg if it is submitted again, and opus never appears as a source slug. bitrate_kbps controls the lossy encode, and an optional sample_rate may be chosen from the closed set; left out, ffmpeg normally follows the source rate. The input's duration is checked first, then the first audio stream alone is encoded, excluding video, metadata and chapters. Pinned ffmpeg and bit-exact flags make repeated calls return the same bytes. With no bitrate given the encoder's default rate applies, and for the recorded low-rate mono examples that default produced larger files than the MP3 default.
04Errors
| Code | HTTP |
|---|---|
invalid_input | 400 |
blocked_target | 403 |
unreachable_target | 424 |
upstream_timeout | 424 |
unsupported_content_type | 415 |
too_large | 413 |
unprocessable | 422 |
internal | 500 |
When each is raised, and what it means for payment: /docs/audio-convert.
05Questions
- What does it cost to convert Ogg to Opus?
- $0.003 per call, paid in USDC on Base via x402.
- How large can the Ogg file be?
- Up to 100 MB (104,857,600 bytes), and at most 60 min (3,600 s) of media. 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.