Reading m4a/mp4 files on Windows

Hi,

I’m trying to load an .m4a or .mp4 file using WindowsMediaAudioFormat but createReaderFor() fails.

I have:

  • Enabled WindowsMediaAudioFormat in the Projucer.

  • Verified that it is a registered format in AudioFormatManager.

  • Confirmed that the file is an AAC .m4a.

Looking at the JUCE source, it seems that .m4a and .mp4 are not included in the extension list:

static const char* const extensions[] = { ".mp3", ".wmv", ".asf", ".wm", ".wma", nullptr };
// juce_WindowsMediaAudioFormat.cpp (line 136)


Does this mean there is no way to load .m4a or .mp4 audio files using JUCE on Windows?

Thanks!

1 Like

just wondering. have you tried modifying the array, adding your type and follow what happens in a debugger ?

Thanks for the response @otristan! I did consider that, but from what I can see, simply adding .m4a or .mp4 to the extensions array would only make the format claim to support those files. It wouldn’t add actual decoding support. My understanding is that WindowsMediaAudioFormat relies on the older Windows Media codecs, which don’t handle AAC .m4a / .mp4 files.

Have you (or anyone) had success loading AAC .m4a files this way after adding the extension? If it should work in theory, I can try patching it locally and step through in the debugger to see exactly where the reader fails.

1 Like

Follow the code. Juce team helps those who help themselves :slight_smile:

I’ve been trying to do this.

Windows Media Player can handle playing .m4a after installing the relevant codec pack from the app store, but JUCE still refuses to play ball. (I’m not entirely sure if the files are AAC wrapped in .m4a though)

I will try changing that array and report back.

Thanks @otristan . As mentioned I have followed the code and my conclusion was that it was not possible load an m4a or mp4 file using JUCE. I assume that I’m not the first one to try this and so I brought this question to the forum to get confirmation on whether it is possible or not. It is a fairly straightforward question. If the question was “Can I read a .wav file using JUCE?”, the answer would be “Yes you can using juce::WavAudioFormat“. My hope was that there would be other JUCE developers here who had already determined whether it is possible or not. Have you been able to successfully read an m4a audio file using JUCE?

Well if WindowsMediaAudioFormat do not open .m4a file even though you have changed the wilcard, I think you have your answer. Vanilla Juce do not support m4a/mp4 files.

This probably requires a whole rewrite using Windows Media Foundation (MFCreateSourceReaderFromByteStream, etc.) as Juce uses an outdated API

IWMSyncReader::OpenStream only supports ASF/WMA/WMV

You can maybe have some luck using an AI to produce this code for you.

HTH