# Weird Export of .M4A format

When Exporting .M4A format audio, the duration is always 1. It seems that the audio is fast-forward played...

Is that a bug and how can I fix it?

Sample code:

ImportString[ExportString[
Audio@Play[Sin[(400 + 400 t) t] + Sin[(430 + 400 t) t], {t, 0, 10}],
"M4A"], "M4A"]


The duration of the output audio is 1 second:

Duration@%


1.02166s

• What version are you running? I'm running 11.2 and this plays for 10 seconds as expected. – Rudy Potter Jun 14 '18 at 16:56
• On MMA 11.3 gives: 1.02166s.Probably a bug! – Mariusz Iwaniuk Jun 14 '18 at 18:46

I found the same problem with version: 11.3.0 for Mac OS X x86 (64-bit) (March 7, 2018)

The documentation for M4A says that MMA follows the ISO/IEC 13818-7 standard and that "a few sampling frequencies from 8kHz to 96kHz" are supported.

The standard lists these sample rates:

isoiec13818rates = {8000, 11025, 12000, 16000, 22050, 24000, 32000,
44100, 48000, 64000, 88200, 96000};


However, only two of the frequencies, 44100 and 48000, result in a correct 10-second sound. Whenever the export and import frequencies don't match, the sound is wrong.

TableForm[{#,
SampleRate /.
Options[ImportString[
ExportString[
Audio[Play[
Sin[(400 + 400 t) t] + Sin[(430 + 400 t) t], {t, 0, 10}],
SampleRate -> #], "M4A"]], SampleRate]} &/@
isoiec13818rates,
TableHeadings -> {None, {"export kHz", "import kHz"}}]

export kHz  import kHz
8000        44100
11025       44100
12000       44100
16000       44100
22050       44100
24000       44100
32000       44100
44100       44100
48000       48000
64000       48000
88200       48000
96000       48000


So SampleRate -> 44100 or SampleRate -> 48000 "fixes" the problem.

ImportString[
ExportString[
Audio[Play[Sin[(400 + 400 t) t] + Sin[(430 + 400 t) t], {t, 0, 10}],
SampleRate -> 44100], "M4A"]]

• Thanks a lot! That solved my problem! – Wjx Jun 16 '18 at 4:36
• You're welcome. I think the problem is a bug, or Wolfram's current version of M4A doesn't fully implement the ISO/IEC 13818-7 standard. – creidhne Jun 16 '18 at 4:59