## How to recover audio from an incomplete or corrupted AAC/m4a file

18

8

I recorded an 85-minute AAC/m4a file using Notability on my iPad. This app has always worked well before but for some reason there was a problem this time. The relevant file shows up as having 21MB (about the right size) and appeared to be recording normally, but when I tried to play it (using Notability or any other player - tried Quicktime, Real Player, Audacity, VLC and WondersharePlayer) it shows up as having zero duration. I am using a Mac with Mavericks installed.

In desperation I ran the file through: http://mp4repair.org/pwt6/preview.html It came up straight away as a 1 hour 25 minute sound file with a 95% "repair score". There is also a preview that sounds right. The only problem is that they want about \$90 for what looks like a pretty simple fix. Can anyone suggest a way that I might be able to get access to this file without paying lots of money? It seems like it should not be difficult but I just don't seem to be able to find the key to the puzzle.

Many thanks in advance for any thoughts/suggestions you might have,

James

Do you mind posting a link to the file? – Mark Durham – 2014-02-19T21:32:54.750

– Stavrosound – 2014-02-19T22:01:02.373

Audacity has a "repair" feature (in the Effects menu). You might try that. – naught101 – 2014-02-19T23:39:04.297

I tried using "treasured", the downloadable programme. It seems mainly aimed at video and only gives a "repair score of 35%". What is more it appears mainly aimed (again) at drumming up business for the expensive repair service those guys are running. That service is probably cheap for professionals, but for a home user it's overpriced (and my guess is the fix is pretty basic). – Jim – 2014-02-20T11:36:25.300

The Audacity "repair" feature will not work because I cannot open the file in Audacity. It says it is not a supported format (I have downloaded the FFmpeg Library and it works with other m4a files). – Jim – 2014-02-20T11:53:00.683

Cannot post a link to the file as it is not uploaded to the web. Happy to send it to someone if they think they might be able to fix it (it was a conference presentation). – Jim – 2014-02-20T12:04:17.880

Have also tried converting the file to other formats, but conversion fails. Tried: http://www.zamzar.com and http://media.io

– Jim – 2014-02-20T12:07:44.267

This worked great for me: http://sysfrontier.com/en/2014/12/31/hello-world/ I used parallels on my Mac, as instructions are for PC.

– None – 2015-09-02T15:29:40.727

im in dire need of assistance in this department cant find any faad for mac im not much of a coder just beginning. and idk how to use the ffmpeg method – None – 2017-05-22T00:14:52.757

This is entirely solvable on a Mac. All you need to do is install faad and faac from MacPorts. So, first install MacPorts (make sure your PATH is properly setup) and then run sudo port install faac faad2 in the Terminal. After this, you can run the commands in @namford's answer, with the only difference being that you do not run the commands with an .exe suffix. It should work exactly as described for Windows, but now you're running the program natively on the Mac.

– GDP2 – 2018-09-20T06:03:05.313

12

This guide worked 100% for me - it takes you through each step. Afterwards, the m4a file plays! Note: this is completely free. http://sysfrontier.com/en/2014/12/31/hello-world/

Also pasting instructions in case the link goes down in future:

How to fix corrupted voice memo (m4a) files.

Do you have broken voice memo files? You can fix those files by yourself. I will show you the steps in this article. Voice memo files have the extension “m4a”. It is audio data encoded in the AAC format and encapsulated in MPEG4 file container. You may fix files recorded with other programs like QuickVoice or on Android. File extensions may be mp4 or 3gp.

The m4a files get broken when some parts of header lost correct information. For example, when the bytes indicating the length of the audio data become 0, the file can not be replayed any more on iPhone, iPad, Mac or Windows PC.

But, in some cases you can fix the broken header by yourself by extracting the audio data, encoding it, and putting it into the new file container.

Let’s do it together.

STEPS for Windows PC

Extract faac.exe from the downloaded zip file. Place it in the same folder as above.

1. Place the file to the same directory.

Move your voice memo file from your iPhone to PC via iTunes. You can use other tools like iFunbox.

Please place the copied file to the same directory as where you placed the above faad.exe and faac.exe. We call the file “20140615 163625.m4a”, for example.

1. Open the file with binary editor.

Please copy the broken m4a file to some folder for backup. Start HxD or your binary editor program and open the broken m4a file.

Press F key with control key to open the Find box. Type “mdat” and press the Find button.

Select from the beginning of the file to the “t” of “mdat” as shown below.

find_mdat

Press Delete key to delete the selected area. Press S key with control key to save.

Press R key with Windows key to open the dialog. Type “cmd” and press OK button to open the Command Prompt.

In the command prompt window that was opened, type “cd Downloads” to move the Downloads folder. Type faad.exe “20140615 163625.m4a” and press the Enter key. In seconds or tens of seconds, you will find the decoded wave file named “20140615 163625.wav“.

Check if the command histories are like below. cmd1

1. Encode by faac.exe

In the command prompt window, type faac.exe -b 160 -o repaired.m4a “20140615 163625.wav” and press the Enter key.

In seconds or minutes, you will find the encoded file named repaired.m4a. Please replay the repaired.m4a to see the audio content is what you want.

Check if the command histories are like below. cmd2

Company Information

SysFrontier Inc. 3-23-16, Ekoda, Aoba Ward, Yokohama, 225-0005, Japan.

1The suggested link did not work for me. I got the following error when I ran FAAD.EXE: Error: Bitstream value not allowed by specification 0% decoding Audio.m4a – Jim Harlan – 2017-11-28T18:47:24.197

1I followed the above instructions and was successfully able to restore critical interviews I had recorded with my Android phone in M4A format. These steps saved me on Windows 10! Thanks! :) – Eric Hepperle - CodeSlayer2010 – 2018-02-10T21:12:36.003

1This also worked for me on macOS, using HexFiend as hex editor and installing faad2 using homebrew. Thanks! – intagli – 2019-01-23T15:11:13.057

1Also works great on Ubuntu Linux, just used GHex as the hex editor and removed the ".exe" part from the commands. – QwertyChouskie – 2019-01-25T21:57:36.713

On macOS, after deleting the starting parts in a hex editor, install faad2 and faac audio decoder and coders: brew install faad2, brew install faac. Then decode corrupted m4a file: faad corrupted.m4a generating wav file then encode it faac -b 160 -o repaired.m4a corrupted.wav. – Gürol Canbek – 2019-05-09T19:18:29.150

@GürolCanbek my corrupted .m4a file is about 8.5mb, my extracted .wav file with faad is about 52mb but it's only 5 minutes long, what is wrong here? – Theo Bouwman – 2019-07-23T10:10:34.430

It helped, thanks a lot! – Mariia Illarionova – 2019-07-31T19:24:13.847

3

You could try rewriting the file using ffmpeg with the following command:

ffmpeg -i damagedfile.mp4 -c copy fixedfile.aac


Alternatively you may use FAAD and a hex editor (e.g. Hexplorer). Find out where the actual data starts in a hex editor. Not always after the mdat entry - there may be alot of zeros in the beginning of the file. Simply copy everything afterwards to a new binary file, e.g. raw.aac. For the AAC format, every sample seems to begin with 0x21, which is a hitn that you found the right position.

You then use FAAD to convert the corrected file using this command:

faad.exe -a out.aac raw.aac


If you are using a hex editor, what can help is to use 2 files: a good one and the corrupted one. If you look at the headers in both, you can spot dramatic differences and those may be problems. If your corrupted file is supposed to be 10 minutes, use a good 10 minute file for comparison. – Simon White – 2016-02-09T15:36:56.747

In the file I had, there was a lot of 0xa5 just before 0xe0 and then the 0x21 as pointed out (597 bytes in, in my case). Cut the file so it started from 0x21 (on Linux: dd if=original-file of=cut-file bs=1 skip=597) and ran it through faad. Got Error: Array index out of range but the file plays like a treat, only thing is that at the end, mplayer complains Error decoding AAC frame header.. Thanks! – thomasa88 – 2016-07-01T19:13:51.903

@thomasa88 I have deleted about 6 instances of the . and previous before .! but every time I get the same error : Bitstream value no allowed by spec. Any ideas? – SeanJ – 2019-05-21T00:21:36.353

0

Reaper is a quite successful DAW in opening corrupt and unsupported audio files and may help with this problem. It is not free but has a 60-day unlimited and never expiring trial which will be more than enough for your case.

"60-day unlimited and never expiring trial"; isn't that a paradox? – Marc W – 2017-09-28T15:21:55.940

@MarcW No it is not a paradox. It just means the producer doesn't enforce a digital copy protection. This doesn't mean that the license extends beyond 60 days. – Guney Ozsan – 2017-10-21T12:01:28.913