Monkey’s Audio stores its tags at the end of the file as a list of named items, after the terminating data. WavPack, TTA and Musepack use the same tag. Numbers are little-endian. APEv1 has only a footer; APEv2 may also have a header.
Layout
| Part | Size | Notes |
|---|---|---|
| Header | 32 | Optional, APEv2 only |
| Items | varies | In the order written |
| Footer | 32 | Always in APEv1; usual in APEv2 |
Header and footer
Both have this layout, and a reader finds the tag from the footer at the end of the file. A tag at the end of a file must have at least a footer; one at the start (strongly unrecommended) at least a header. APEv1 does not use the flags: they are zero when written and ignored when read.
| Offset | Size | Type | Field | Meaning |
|---|---|---|---|---|
| 0 | 8 | char[8] | Preamble | APETAGEX |
| 8 | 4 | uint32 | Version | 1000 for APEv1, 2000 for APEv2 |
| 12 | 4 | uint32 | Tag size | Bytes of the items and the footer, not the header |
| 16 | 4 | uint32 | Item count | Items in the tag |
| 20 | 4 | uint32 | Flags | See below |
| 24 | 8 | bytes | Reserved | 0 |
| Flag bit | Meaning |
|---|---|
| 31 | The tag has a header |
| 30 | The tag has no footer |
| 29 | This 32-byte block is the header; 0 means the footer |
| 3 to 28 | Undefined, must be zero |
| 1 and 2 | Item type, in items |
| 0 | Read-only, in items |
Bit 30 is read two ways. The original text is Frank Klemm’s own page
apetagflags.html (the Internet Archive’s copy of 12 December 2006, author meta tag “Frank
Klemm”): “Bit 30: 0: Tag contains a footer, 1: Tag contains no footer”. The Hydrogenaudio
Knowledgebase copied it on 26 April 2005 with the same words and kept them through five revisions to
2006; on 14 November 2017 an anonymous edit, summary “fixed the swapping of yes / no”, reversed it to
“0: tag contains no footer, 1: tag contains a footer”, which is what the page says now (revisions
4579 to 13445 against 27567; the 2020 and 2024 copies show the reversed text). The
original specification therefore means “bit 30 set: no footer”; the 2017 edit has no source of its own.
Programs split the same
way. Bit 30 means “no footer” in FFmpeg (LACKS_FOOTER), mutagen
(HAS_NO_FOOTER) and TagLib (footerPresent = !flags[30]), and FFmpeg,
WavPack and TagLib write their footers with the bit clear. It means “contains a footer” in the
Monkey’s Audio SDK (CONTAINS_FOOTER, which its default flags set) and in lofty-rs. The
table follows the older text; since the two readings contradict each other, find the footer by its
preamble at the end of the file and do not rely on this bit.
Items
| Size | Field | Meaning |
|---|---|---|
| 4 | Value size | Bytes of the value |
| 4 | Item flags | Bit 0 is read-only; bits 1 and 2 are the type, below |
| varies | Key | ASCII, 2 to 255 characters, ending in a zero byte |
| value size | Value | As the type says |
| Type | Value holds |
|---|---|
| 0 | UTF-8 text; several values may be separated by zero bytes |
| 1 | Binary; usually a description, a zero byte, then the data |
| 2 | An external locator, UTF-8: a URL or a file name (http://host/dir/file.ext, file.ext, /dir/file.ext, DRIVE:/dir/file.ext) |
| 3 | Reserved |
A key has 2 to 255 characters from 0x20 to 0x7E and ends in a zero byte. The keys ID3,
TAG, OggS and MP+ are not allowed. Keys are case sensitive,
but two keys in one tag must not differ only in case, each key occurs at most once, and readers are
recommended to compare without regard to case. Text values are not zero terminated; several values
in one item are separated by zero bytes. Items should be sorted by size, smallest first; the
specification says this is strongly recommended and not a must. The usual keys are listed on
the MP3 APE tags page.
What the Monkey’s Audio SDK writes and reads
- Version and flags. It writes version 2000 with a footer and no header, and accepts versions up to 2000. Its source names bit 30
CONTAINS_FOOTERand sets it in the flags of the tags it writes, while the APEv2 description (and the table above) calls that bit “no footer”. So a tag written by the SDK has bit 30 set and a footer: a reader should find the footer at the end of the file by itsAPETAGEXpreamble and not rely on this bit. - Where. The tag follows the terminating data. An ID3v1 tag (128 bytes, “TAG”, 30-byte title, artist and album, 4-digit year, 29-byte comment, track, genre) may follow the APE tag; the SDK looks for both at the end of the file, the ID3v1 tag first. A file of version 3.99 made by an old build may have the tag counted as terminating data; the SDK used to correct this, and no longer does.
- Size. The tag may be up to 256 MB.
- Names the SDK defines. Title, Artist, Album, Album Artist, Comment, Year, Track (a number, or “3/12”), Disc, Genre, Cover Art (front), Notes, Lyrics, Copyright, Buy URL, Artist URL and Publisher URL. Other keys are free.
- Cover art is a binary item whose value is a file extension or name (
jpg,cover.png; older builds stored the whole file name), a zero byte, and the image file. A reader decides by looking for a dot. The explorer shows an image found this way, whatever the key, when the data starts like a JPEG, PNG, GIF, BMP or WebP. - Several values in one text item are separated by zero bytes.
- Image link files. The tag after the text of an .apl file is read the same way.
Source: Monkey’s Audio SDK 13.46, Shared/IAPETag.h (the footer layout, the tag and item flags, the item types) and FFmpeg’s apetag.c. The APEv2 specification on wiki.hydrogenaud.io answers HTTP 403 when fetched directly; its pages (specification, header, item, flags, key, item value) were read from the Internet Archive’s copies and are compared with these pages by scripts/ape/spec-check-apetag.mjs. The original text by Frank Klemm was not found in the archive. For bit 30, the copies of the flags page of 2010, 2015, 2020 and 2024 and the sources of FFmpeg, mutagen, TagLib, lofty-rs, WavPack and the SDK are listed in research/ape/spec/apev2/SOURCES.md. The SDK’s name for bit 30 (CONTAINS_FOOTER) and FFmpeg’s (LACKS_FOOTER) are opposite; the page says so above and in the list below.