Join Nostr
2025-04-19 18:36:21 GMT

Zhuowei Zhang on Nostr: I spent all morning trying to decode the Apple Positional Audio Codec (APAC)’s ...

I spent all morning trying to decode the Apple Positional Audio Codec (APAC)’s GlobalConfig from its MPEG4 Sample Description Box (stsd).

If you want to follow along:

the codec is in /System/Library/Frameworks/AudioToolbox.framework/AudioCodecs
See apac::GlobalConfig::Serialize and apac::GlobalConfig::Deserialize
If you need a sample file:
afconvert -o sound.m4a -d apac -f mp4f sound.wav
Or grab a sample file from https://trac.ffmpeg.org/ticket/11480
Pull the stsd from the m4a with mp4extract --payload-only moov/trak[0]/mdia/minf/stbl/stsd/apac sound.m4a sound_config.bin
The config starts after dapa then 4 0x00 bytes
First two bytes of the apac bitstream are 0x08 0x00 (see IsAPACBitstreamVersionValid / ACAPACBaseEncoder::GetMagicCookie)
followed by the GlobalConfig