Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Essentials of macOS to read and write mp3 and mp4 audio files

Hi,

On macOS I used to open MP3 and MP4 files with ExtAudioFile. For a few years it doesn't work anymore.

So I decided to try different macOS API using the AudioFileID of AudioToolbox framework.

I decided to write a test:

https://gist.github.com/joelkraehemann/7f5b241b52ca38c3a765c138fb647588

It fails right here:

AudioFileOpenWithCallbacks()

By telling OSStatus error 1954115647, which means kAudioFileUnsupportedFileTypeError.

The filename was set to an MP4 file:

~/Music/test.mp4

Howto fix this?

regards, Joël

Hi Joël,

I'm surprised to hear that you're unable to open MP3/MP4 files with ExtAudioFile. That should still work today. ExtAudioFile is layered on top of AudioFile and both should work for these file formats. If you could attach an example file that you're having trouble opening with these APIs, I'd be happy to check to see what might be wrong.

Also, macOS ships with tools afinfo and afplay which you can use to verify and play back audio files. These use the same frameworks which implement the AudioFile APIs. Could you try out these tools with one of the problematic files and see what they report and/or play back?

Thanks!

-- rhymu

Essentials of macOS to read and write mp3 and mp4 audio files
 
 
Q