.m4a sound file support

Hello peeps,

I found a pretty useful “standard” for sound files in Babylon.js.

ffmpeg, a tool for video and audio conversion, can be build with a special encoder called libfdk_aac. This encoder can create m4a sound files with very good sound quality while it’s bitrate is very low.

Here’s the command for the HE-AAC version 2 profile, which is the most optimal one for low bitrate:
ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he_v2 -b:a 32k output.m4a

The results are pretty straightforward:

The song I’ll be testing is Danger Snow - Dan Henig from the YouTube Audio Library (Royalty Free).

  • 320k bitrate mp3 (original) - 5.1MB
  • 128k bitrate mp3 (lowest tolerable bitrate) - 2.1MB
  • 32k bitrate m4a - 538,9KB

All files can be downloaded here (including the unusable 32k and 64k mp3 soundfiles).

So we have a whopping 1.6MB difference in file size!

The browser support of .m4a files is better than .ogg, since .ogg can’t be used in Safari browsers.

All I hope for is support for this format in the BABYLON.Sound object.

I’m currently using a workaround like this:

    const context = new AudioContext();
        .then(response => response.arrayBuffer())
        .then(arrayBuffer => {
            const sound: Sound = new Sound(
                    loop: true,
                    autoplay: true

Could you create a quick playground with the m4a files not working ? I ll try to see how we can add support after.

.m4a files just aren’t being loaded. Looking at the Sound.ts file on GitHub, I can see there is no check for .m4a files, only .mp3, .ogg, .wav and blobs.

Ok will be in the next nightly in a couple hours, thx

Thank you as well :slight_smile: