catalogue / tools / Audio & video / FLAC to AAC

Convert FLAC to AAC

To convert FLAC to AAC, send one POST to /v1/audio-convert with the FLAC 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

01Limits

LimitValue
Largest source file100 MB (104,857,600 bytes)
Longest input60 min (3,600 s)
Timeout94 s
Source formatsAIFF, AVI, FLAC, MKV, MP3, MP4, Ogg, WAV
Output formatsAAC, FLAC, MP3, Opus, WAV

02Example

A real FLAC to AAC run of audio-convert.

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

{
  "url": "https://grist.tools/samples/av/convert-beeps.flac",
  "to": "aac"
}
Response
200 OK
payment-response: <base64 settlement receipt>

{
  "source_url": "https://grist.tools/samples/av/convert-beeps.flac",
  "bytes": 32086,
  "source_container": "flac",
  "format": "aac",
  "bitrate_kbps": null,
  "sample_rate": null,
  "audio_bytes": 5268,
  "audio_base64": "//FsQEcf/AEIVCwkSCWOhseh2GBMWgoSxP/FVWquNyXXqT27fHGt/by8JON5JU//..."
}

Source file: av/convert-beeps.flac, 31.3 KB (32,086 bytes). Two-second mono 16-bit FLAC at 8 kHz holding the same three rising 500 Hz beeps as waveform-beeps.wav, written with uncompressed verbatim subframes by a TypeScript generator. The recorded run returned 5.1 KB (5,268 bytes) of AAC, 16% of the source size, with the source read as the flac container. Decoded, the AAC in audio_base64 opens with FF F1 6C 40 47 1F FC 01 08 54 2C 24. Recorded with ffmpeg 8.1.2.

In the sample itself: its 34-byte STREAMINFO block, in its own field order, declares blocks of 4,096 samples, no largest frame size, 8,000 Hz, 1 channel, 16 bits per sample and 16,000 samples in total. 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 568 bytes, and buffer fullness 0x7FF, the value that marks a variable bitrate stream.

03Format notes

FLAC as a source

A native FLAC stream begins with the four ASCII characters fLaC, and that marker is what Grist sniffs. FLAC compresses audio losslessly, so decoding restores the exact samples that were encoded. audio-convert is the only service that reads the format directly, and its own canonical example decodes a FLAC file to a bit-exact PCM WAV. FLAC audio can also sit inside other containers as a stream, but such files are recognised by their container signature and reported under that container, not as flac. Before encoding, the stream length is measured and checked against the service's duration limit. Like every audio-convert source, only the first audio stream is used, metadata and chapter information are stripped, and the pinned ffmpeg with bit-exact flags makes the result reproducible. A lossy destination discards information the FLAC still held.

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

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/audio-convert.

05Questions

What does it cost to convert FLAC to AAC?
$0.003 per call, paid in USDC on Base via x402.
How large can the FLAC 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.

06Related