Introduction
CAF is Apple’s audio file format for macOS and iOS, part of Core Audio. It was designed to replace AIFF and WAV inside Apple’s software: its sizes are 64-bit, so a file has no 4 GB limit, and it can hold any format Core Audio supports, from plain PCM to AAC and Apple Lossless.
Most CAF files met in practice hold uncompressed PCM, for example sound effects in apps and audio exported by Apple’s tools.
Structure
A CAF file starts with an 8-byte file header: the type caff, a 16-bit
version (1) and 16-bit flags. Chunks follow, each a four-character type and a signed
64-bit size, all big-endian. The audio description chunk desc comes first
and gives the sample rate (as a 64-bit float), the format ID, format flags, bytes and
frames per packet, channels and bits per channel.
The audio data chunk data starts with a 4-byte edit count, then holds the
audio. Its size may be −1 when it is the last chunk and its length was not known while
recording. Formats with packets of varying size also need a packet table chunk
pakt. Optional chunks carry the channel layout, markers, regions and
text information. The reference pages cover each of them:
Header and chunks,
Audio description,
Audio data and packets,
Channel layout,
Markers and regions and
Other chunks.
0File header caff, version, flags8 bytes8desc chunk header and audio description44 bytes52Optional chunks chan, pakt, info, mark …varies…data chunk header, edit count, audiovaries
Not described
These pages follow Apple’s Core Audio Format Specification 1.0 (downloaded and read in full), the Xcode
SDK’s CoreAudioBaseTypes.h for the channel layouts, labels and format IDs it adds, and what
the files on this Mac and the files afconvert writes show for the cookies and chunks Apple does
not describe. The explorer reads the file header and every chunk the specification defines
(desc, data, pakt with its variable-length integers,
chan, kuki for each codec, strg, mark, regn,
inst, midi, info, edct, ovvw,
peak, umid, uuid and free) field by field, every byte
in the tree, with the chunks checked against one another. It plays linear PCM (8 to 64 bits,
both orders, integer and float), µ-law, A-law, Apple IMA4, AAC (LC, HE-AAC, HE-AAC v2, AAC-LD), Apple
Lossless, FLAC, Opus, IMA ADPCM and Microsoft ADPCM in WAVE blocks, GSM 06.10 (in WAVE blocks and as the plain
frames of agsm), AC-3 (also inside IEC 60958 as cac3), MPEG Layers I to III (also as
ms 00 55), AAC-ELD (with and without low-delay SBR) and ELD v2 (aacg) with its low-delay
MPEG Surround 212 upmix to stereo, USAC (the frequency-domain core only: no eSBR, LPD or MPEG Surround), iLBC, QCELP, QDesign Music 1 and 2, MACE and AMR narrowband;
the other format IDs are named and labelled. For the compressed formats the packet table cuts the audio into
packets, the magic cookie configures the decoder, and the priming and remainder frames are cut off, so
exactly the valid frames play.
Checked against Apple’s own decoder: afconvert made files in every format it can write into a
CAF, and each decode was compared with afconvert’s own to 16 bits: PCM in 11 layouts, µ-law, A-law,
IMA4, FLAC, Apple Lossless and AAC are exact to 1 in 32,768; HE-AAC, HE-AAC v2, AAC-LD and Opus agree to
1 to 6 in 32,768 on the built files. Of the 2,431 distinct .caf files on this Mac (573 PCM, 1,341 AAC, 513
Opus, 3 IMA4, 1 Apple Lossless; the viewer shows all of them, every byte in the tree), the comparison results are in
the progress notes.
Known, not yet covered
- Viewer: QDesign Music 2 is decoded by the shared port of FFmpeg’s
qdm2.c: the real file of FFmpeg’s FATE suite, put in a CAF, decodes to FFmpeg’s samples within 1 (the cookie holds the same QuickTime wave atoms). QDesign Music 1 (QDMC) is decoded by a port of FFmpeg’sqdmc.c: two real 44.1 kHz files from FFmpeg’s sample server decode to FFmpeg’s samples within 1 in 32,768 (109 dB); Apple’s decoder refuses a QDMC stream here, so no Apple comparison exists, and the CAF cookie and packet layout (the same QuickTime wave atoms, one frame a packet) is taken from the QuickTime file. QUALCOMM PureVoice (Qclp) is decoded by a port of FFmpeg’sqcelpdec.c: the FATE file agrees with FFmpeg to 124 dB; the packets are read as the QCP frames, with or without the rate byte. iLBC is the shared decoder with RFC 3951’s enhancer, which agrees withafconvertto 25 to 32 dB (against 13 to 26 dB before) and with a compiled copy of the RFC’s reference decoder to 24 to 32 dB; the rest is the integer decoder (the WebRTC code FFmpeg carries) against the RFC’s floating point, not the enhancer (the enhancer alone matches the RFC’s C to 132 dB). MACE 3:1 and 6:1 (the shared decoder, checked sample for sample against FFmpeg by the AIFF tests) are now decoded. AMR narrowband (samr) and AMR wideband (sawb) are decoded by the sharedamr-nb.jsandamr-wb.js, which reproduce the 3GPP conformance sequences bit for bit (see AMR); a CAF built from frames of the 3GPP reference encoder (narrowband) or from the stored conformance sequences (wideband) decodes to exactly the reference decoder’s samples, from the start and after a seek. The packet layout it assumes (a frame-type byte, then the bits, one frame a packet) is read from FFmpeg’s CAF demuxer. - Viewer: labelled as not decoded, although each has public source code or a public
specification: MPEG-4 CELP and HVXC (
celp,hvxc; ISO/IEC 14496-3 subparts 3 and 2, whose reference software was not found online: FFmpeg has no decoder for either, the ISO standards site, the Hannover and SourceForge MPEG-4 reference mirrors and GitHub searches gave nothing, andafconvertcannot write them); MPEG-4 TwinVQ (twvq, object type 7: FFmpeg’stwinvqdec.creads only the VQF/Metasound form, itsmpeg4audio.hmarks object types 7 to 9 unsupported, and no MPEG-4 sample exists:samples.mplayerhq.huhas VQF files only); MPEG Surround as a format of its own (aacs, ISO/IEC 23003-1: the 5-1-5 and 5-2-5 trees, the 7-x-7 trees, residual and arbitrary-downmix coding are not decoded; FFmpeg does not decode MPEG Surround andafconvertcannot writeaacs, so there is no stream to check them against. Only the one-to-two (212) box is decoded, for ELD v2; see below). The streamstime(IOAudioTimeStamps),midi(MIDIPacketLists) andapvs(Float32 parameter values) are described on the Audio description page fromCoreAudioBaseTypes.hand are not shown as values. - Viewer: USAC (
usac) is decoded for its frequency-domain core only (arithmetic coded spectrum, noise filling, TNS, mid/side and complex-prediction stereo, all window shapes, 1,024-sample frames: five ISO/IEC 23003-3 conformance streams from FFmpeg’s FATE suite, put in CAFs, agree with the ISO reference and withafconvertto 64 to 95 dB). Not decoded, and shown as silent frames with a problem listed: eSBR, the linear-prediction core (ACELP and TCX frames) with its transitions, MPEG Surround 212 (the downmix plays: the 212 box itself is written and decoded for ELD v2,aac-mps.js, but USAC needs the hybrid filter bank in front of it, the phase-coding and residual variants of the parameters, and eSBR after it, and no USAC stream with MPEG Surround exists here to test it with), time-warped MDCT, 768-sample frames and the DRC data (read to be skipped). The source is FFmpeg’saacdec_usac.c(which parses the MPEG Surround 212 data and does not decode it) and Fraunhofer’s fdk-aac;afconverthere decodes USAC but cannot write it (-d usacfails with “fmt?” in every container and at every rate tried), and no stream with those tools was available to check them against (the open xHE-AAC encoderexhalecould make some but was not built). Ittiam’s libxaac (Apache-2.0) decodes USAC with eSBR, LPD and MPEG Surround 212 and is the source to port them from; it was built here from source (plain C,xaacdecandxaacenc) and serves as a second decoder: its output agrees withafconverton the five conformance streams to 65 to 87 dB, and streams its encoder wrote for single tools (84 files insamples/caf/usac-xaac: 1,024 and 768-sample frames, eSBR 2:1, 4:1 and 8:3 with the harmonic transposer, inter-TES and PVC, MPEG Surround 212, the switched and the time-domain core) show that the frequency-domain core with mid/side stereo agrees with it to 68 to 80 dB; the same streams with noise filling and complex prediction enabled in the encoder agree only to 19 dB on noise. Narrowed down on 2026-11-19: complex prediction alone agrees to 67 dB (as plain mid/side does), noise filling alone gives the 19 dB; the two outputs have the same level (rms within 0.1 %) but the random noise sequence differs, and no choice of the two channels’ starting values (0, 0x3039, 0x10932) reproduces libxaac’s. The conformance stream with noise filling agrees to 80 dB with the present values, so whether libxaac or this decoder is right is not decided: it needs a trace of libxaac’s noise bins, which was not made. AAC-ELD (aace) is decoded and agrees withafconvertto 88 to 92 dB on tones and sweeps (50 dB on noise); ELD with the error-resilience flags set is refused. - Viewer: AAC-ELD with low-delay SBR (what
afconvert -d aacfwrites; the file’s format ID is stillaace, the SBR is signalled in the AudioSpecificConfig’s ELDSpecificConfig) is decoded, single and dual rate, mono and stereo with coupling, with the complex low-delay filter bank (32-band analysis, 32 or 64-band synthesis) and the one-bit frame class grid of 4.6.18 for low delay. Eight built files (tones, sweeps, pink and white noise, bursts, 32, 44.1 and 48 kHz) agree withafconvertto 70 to 90 dB; the filter banks equal Fraunhofer’s fdk-aac library’s integers to rounding, and the whole decoder agrees with the library (in its complex-QMF mode) to 69 to 82 dB. The exception is a stereo sweep that leaves the core’s band: the SBR then rebuilds it from subbands holding only the tone’s leakage 75 dB down, and the library andafconvertthemselves differ by 43 dB there, so 26 dB is all that file can show. The extra 32 samples of the SBR synthesis (64 at dual rate) are taken out like the priming. - Viewer:
aacg(ELD v2: a mono core at half the rate, dual-rate low-delay SBR and a low-delay MPEG Surround 212 upmix to stereo; the file says one channel at the core’s rate and plays two) is decoded: the LdSpatialSpecificConfig is read from the ELD extension of type 2, the spatial frame from theEXT_LDSAC_DATApayload after the SBR data (Huffman-coded CLD and ICC with pair, time and frequency differences, PCM escapes and parameter-set interpolation), and the 64-band QMF-domain mono signal of the SBR becomes left and right through the OTT matrix, the smoothing and the all-pass decorrelator before the synthesis bank (the code follows Ittiam’s libxaac, Apache-2.0; the CLD, ICC and matrix tables are computed from the standard’s formulas and the code trees are checked as complete prefix codes). Againstafconvert(the only oracle: FFmpeg stops at “not yet implemented” and the fdk-aac library fails with error 0x5): tonal material agrees to 32 dB for the stereo signal (41 dB for the mid), noise and correlated-noise material to 15 to 18 dB (correlation 0.975 to 0.99 per 512-sample block), with the level of each channel within 0.3 dB in every case. Two faults were found on 2026-11-19, both common to libxaac as it is built and this decoder, and both were the reason noise at 32 and 48 kbit/s was only 4 to 6 dB. (1) The low-delay EcDataPair has no direction bit: time differences always run backwards. libxaac reads one when the first set is time-coded and the second frequency-coded, loses its place and cannot parse about a fifth ofafconvert’s spatial frames (fdk-aac’sEcDataPairDec, read as a reference, does not read it for the low-delay form); with the fix every spatial frame of the nine sample files ends where its access unit does (0 to 7 bits left, or whole zero bytes of padding, or 1 or 2 bits short in 4 %). (2) With the low-delay MPEG Surround filter banks the analysis and synthesis banks carry a phase of jband against the SBR ones: bands that pass through are not affected, but an SBR patch that copies band p to band k comes out turned by jk − p, and since patch shifts are even, the patches whose shift is 2 mod 4 arrived upside down (a correlation of −0.93 in 9 to 14 kHz at 32 kbit/s, found with a per-band phase comparison). The decoder applies that rotation when the stream has spatial data. What is left: the SBR noise floor and sine components above the core are not matched to Apple’s sequence (correlation about 0.92 in the SBR bands), the decorrelator in its fine detail, and a few blocks in the correlated files’ right channel. The dual-rate low-delay SBR without MPEG Surround is not at fault (afconvert’s output has only its 16-bit rounding floor above the core’s band: white noise at 32 kbit/s stops at 8 kHz, at 64 kbit/s at 16 kHz; where the SBR band holds a signal, 8 to 16 kHz at 64 kbit/s, this decoder agrees withafconvertto 100 dB). Not decoded: trees other than 212 (the 5-1-5, 5-2-5 and 7-x-7 trees), residual and arbitrary-downmix extensions, temporal envelope shaping and temporal processing (parsed, not applied, with a problem listed) and the hybrid filter bank of the non-low-delay form. - Viewer: what was tried for the formats still not decoded (2026-11-19): (1) the ISO/IEC 14496-5
reference software, listed by multimedia.cx as
standards.iso.org/ittf/PubliclyAvailableStandards/c050470__ISO_IEC_14496-5_2001_Amd_20_2009_Reference_Software.zip(and Amd 12, c045527): the server returns an HTML page of 6 to 8 KB in place of the zip, also through the Wayback Machine in 2013, 2016, 2019 and 2024; (2) GitHub repository searches for HVXC, MPEG-4 CELP, MPEG-4 audio reference software, MPEG Surround and MPEG-4 TwinVQ (only an unrelated spatial-audio effects project and VQF players); (3) FFmpeg’stwinvq.c/twinvqdec.chandle the VQF and Metasound frame layouts, not the MPEG-4 subpart 4 bitstream, and nothing in them states the MPEG-4 tables; (4) fdk-aac’slibSACdec(MPEG Surround 212 and the low-delay form that ELD v2 uses) was downloaded and read as a reference, and it is built here as a test oracle, but its decoding of anafconvert -d aacgfile fails with error 0x5, so it is no oracle; its licence also forbids copying it, which is why the spatial decoder here follows Ittiam’s libxaac instead (Apache-2.0, found on GitHub asittiam-systems/libxaac: USAC with eSBR, LPD and MPEG Surround 212, and the low-delay MPEG Surround of ELD v2, all in C; it was read and then built, see the USAC item above). - Viewer: every format with a packet table is read as a stream of any length: the waveform at any
zoom, Play from any place and the peak and RMS levels cover the whole sound (a test plays a 9-million-frame file
past the old 8,388,608-sample cap). Formats whose packets decode alone are read at any packet; AAC (with SBR and
parametric stereo), MPEG audio, iLBC, QCELP, QDesign 1, USAC and IMA4 run through the file once and save a copy
of the decoder’s state every few million frames, so a seek resumes exactly; Opus, AC-3, GSM, AMR, QDesign 2 and MACE
restart a fraction of a second before the place wanted, so a window played after a seek can differ slightly from the
first pass (Opus: 78 dB; AC-3’s random dither, which the standard asks for, differs from one decode to the next). The
levels are computed when the file opens, which takes a while for a very long compressed file. (The lists of entries
no longer stop:
strg,info,edct,mark,regn,peak,chan, the Apple Loops tags and the MIDI events open in groups of 256 entries, and an overview’s entries open one at a time.) - Viewer: the
umidchunk, themidichunk (read to its events), theovvwvalues and the whole AudioSpecificConfig (object type, frequency, channels, GASpecificConfig, program config element, ELD, SBR and PS signalling; the whole UsacConfig for USAC) are now decoded. The cookies of QDesign 1 and 2 (FFmpeg’sqdm2.candqdmc.cread aQDCAatom, described on the Other chunks page), AC-3 and CELP, HVXC and TwinVQ are shown as bytes, because their layouts are not described anywhere found. - Viewer: GSM 06.10 (
ms00 31) and MPEG Layer I/II are decoded.agsm(the plain 33-byte frames of FFmpeg’s CAF table; FFmpeg’s publicsample.gsmin a CAF) andms00 55 (MPEG Layer III frames cut from an ffmpeg encode) decode to FFmpeg’s output exactly (more than 300 dB), but Apple’safconvertrefuses both, so the packing is FFmpeg’s reading, not Apple’s. The decoders are the ones the WAVE and MPEG pages use. Microsoft ADPCM uses the standard seven coefficient pairs because CAF has no field for others. - Viewer: AC-3 in IEC 60958 (
cac3) is cut out of its IEC 61937 bursts (the preambleF872 4E1F, the data type in Pc, the length in Pd, 16-bit words, high byte first, in either byte order the format flags give) and decoded as AC-3; how Apple fills its desc fields for it is assumed to be those of linear PCM, which the header calls “the standard flags”. - Viewer: Opus at 24,000 Hz is decoded at 48,000 Hz and low-pass filtered to half the rate, which
agrees with
afconvertto 33 to 49 dB signal-to-noise, not sample for sample (Apple decodes at 24,000 Hz natively); at 48,000 Hz the difference is 45 to 99 dB. - Viewer: AC-3 and E-AC-3 start 256 frames later than the packet table says in Apple’s decoder; that figure, and the 32 frames Apple also drops at the end of a file, come from files made by FFmpeg with no priming in their packet table.
Unknown
- Reference and viewer: the Opus magic cookie (the pages give the seven numbers as read from
files; FFmpeg’s
cafdec.csays the layout is unknown and refuses Opus with more than two channels, so the cookie of a multichannel Opus file is unknown), the iLBC cookie, the APACdapabox and the APAC codec, the Vorbis cookie (vorb), the Audible codec (AUDB), the 21 codes with ap,qorzprefix anddvi8(named only asafconvertlists them), and AES3 audio (aes3): Apple’s header only says it is AES3-2003 as SMPTE 302M and 331M carry it, with no flags; no byte layout for it inside a CAF is published (searched: the SDK headers, FFmpeg’s CAF table, which does not list it, FFmpeg’ss302m.c, which reads SMPTE 302M from MPEG transport streams and says nothing about CAF, libsndfile,afconvert, which cannot write it). - Reference and viewer: the 16 header bytes of the second Apple Loops UUID chunk (the transient
markers) and the 32-bit word in each transient have no meaning in any source found (the open reader
apple-loops-meta-readercalls them unknown); theiXMLchunk’s XML elements are not decoded (the iXML specification’s site has an expired certificate); Amadeus Pro’sCLSTandResUchunks have no known layout and are shown as raw bytes.
Links
Software
- QuickTime Player – Apple’s built-in media player, which plays CAF (macOS)
- Logic Pro – Apple’s professional music production app, which records and exports CAF (macOS)
- GarageBand – Apple’s free music app, which uses CAF for its loops (macOS, iOS)
- VLC media player – free player for almost any audio or video file (Windows, macOS, Linux, mobile)
- FFmpeg – command-line tool that converts CAF to and from other formats (Windows, macOS, Linux)
Developers
- Audio Toolbox – Apple’s framework for reading and writing audio files, CAF included (Swift, Objective-C)
- libsndfile – library that reads and writes CAF (C)
Reference
- Apple Core Audio Format Specification 1.0 – Apple’s full specification of the CAF header and chunks
- CAF File Overview – Apple’s introduction to CAF capabilities and layout
- RFC 3951 – the iLBC codec; RFC 6716 – the Opus codec; FLAC format