Convert MP4 to AAC
To convert MP4 to AAC, send one POST to /v1/audio-convert with the MP4 source and "to": "aac" in the body. Left out, "to" falls back to its default "mp3", so a AAC 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 MP4 to AAC 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.mp4",
"to": "aac"
}200 OK
payment-response: <base64 settlement receipt>
{
"source_url": "https://grist.tools/samples/av/pair-clip.mp4",
"bytes": 11315,
"source_container": "mp4",
"format": "aac",
"bitrate_kbps": null,
"sample_rate": null,
"audio_bytes": 11183,
"audio_base64": "//FsQEV//AEQVCwkah2KhMuwwFjUFCWJ/0yl5qpSSvEt559nE+3Stuq5q1X//2HG..."
}Source file: av/pair-clip.mp4, 11 KB (11,315 bytes). 4 s MP4 made by ffmpeg: a 64x36 PNG video stream at 1 fps (a slate field with a small amber square moving right), a mono 8 kHz FLAC audio track of two 500 Hz triangle beeps, and an English mov_text subtitle stream with two cues. The recorded run returned 10.9 KB (11,183 bytes) of AAC, 99% of the source size, with the source read as the mp4 container. Decoded, the AAC in audio_base64 opens with FF F1 6C 40 45 7F FC 01 10 54 2C 24. Recorded with ffmpeg 8.1.2.
In the sample itself, the ftyp box names major brand isom, minor version 512 and compatible brands isom, iso2 and mp41; the top-level boxes run ftyp, free, mdat and moov, so the moov index comes after the media data; mvhd counts 4,000 ticks at 1,000 per second, 4 s; the 3 tracks are vide with sample entry mp4v, soun with sample entry fLaC and sbtl with sample entry tx3g. In the returned AAC: it opens with an ADTS frame header carrying no CRC: MPEG-4 AAC LC, 8,000 Hz, 1 channel, a first frame of 555 bytes, and buffer fullness 0x7FF, the value that marks a variable bitrate stream.
03Format notes
MP4 as a source
MP4 belongs to the ISO base-media family, and Grist recognises it by the ftyp box type at bytes four to eight rather than by a file extension. QuickTime MOV and other files carrying the same box are sniffed as this one container, and the response names it mp4. The container can hold video, audio and text subtitle streams side by side, and each service takes one kind. audio-convert maps the first audio stream and drops the picture. video-thumbnail puts the seek before the input, so it happens at the demuxer and stays cheap in a large file, then decodes exactly one frame from the first video stream. subtitle-extract selects a text track by its zero-based position among subtitle streams. Each ffmpeg run strips container metadata and sets bit-exact flags, so outputs do not carry creation timestamps.
AAC as a target
AAC output is a raw ADTS stream: ffmpeg's aac encoder writes through the adts muxer, and no MP4 container is built around it. Each ADTS frame carries its own header, and the stream is written straight to a pipe without a seekable file. The bitrate_kbps setting applies, but AAC has its own lower ceiling, because it is the slowest encoder of the set and that ceiling keeps a maximum-length input inside the encode deadline. Only the first audio stream is encoded; video, metadata and chapters are dropped, and bit-exact flags keep output reproducible for the pinned ffmpeg. sample_rate is optional, otherwise ffmpeg normally keeps the source rate. AAC is a destination only: a raw ADTS file would pass the MPEG frame-sync sniff, yet nothing proves ffmpeg would receive the right demuxer, so it is not accepted as a source.
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 MP4 to AAC?
- $0.003 per call, paid in USDC on Base via x402.
- How large can the MP4 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.