An APEv1 segment always ends with a 32-byte footer that begins with the ASCII signature "
APETAGEX". Typically, the segment will be at the very end of the audio file, or just before an ID3v1 segment. So, the signature usually begins either 32 or 160 (32+128) bytes from the end of the file.
An APEv2 segment usually has the same style of 32-byte footer as with APEv1, and usually also begins with a 32-byte header that has essentially the same format. So, usually, the "
APETAGEX" signature will appear twice. However, it is legal to omit either the header or the footer, if it is deemed not to be necessary. In part due to the header, an APEv2 segment can potentially be at the beginning of the file, or somewhere else.