Unsupported Browser

This page probably won't work great in Internet Explorer. We generally only support the recent versions of major browsers like Chrome, Firefox, Safari and Edge.

What is AAC?

AAC is the audio encoding format that has become the standard for capture and delivery in consumer markets.

Music sold on the iTunes Store comes encoded in AAC format. iTunes encodes songs in AAC format by default.

At similar bit-rate, AAC achieves better quality than MP3 encoding.

A dvanced A udio C oding

Repair of corrupted AAC files

AAC is difficult to repair due to lack of headers in AAC frames.

AAC can be found in audio files, usually in QuickTime and MP4 files using the extensions .m4a .m4b .m4p .mov and rarely as raw streams in .aac .adif and .adts files.

Repair consists in reindexing the AAC frames into a .M4A / MOV file.

In video files, AAC is often used to encode audio. It is common to find AAC paired with H.264 or H.265 video formats .

Treasured can detect AAC in damaged audio files.

Warning: Voice Memos bug in iOS

Since fall of 2018, at Aero Quartet we have observed a surge of requests to fix audio recordings made with an iPhone and Voice Memos app.

  • In iOS 12, Voice Memos app has a feature called Replace to edit an original recording.
    Replace is not reliable and can corrupt the original recording.
  • Corrupted recordings can be repaired, but are significantly shorter in duration than originals.
    The missing duration is lost forever.
  • The problem seems to have been solved in iOS 13.

Consult dedicated blog post for more information.

Try Treasured on your damaged AAC audio files!

Our service offers:

  • FREE diagnostics and preview with Treasured
  • FREE sample of repaired video
  • Try before you buy with a FREE trial of your Repair Kit
  • Enjoy FREE customer support by speaking directly with our trained experts
  • Invaluable expertise, dedication and second to none customer service
Video Repair app online


Video Repair — online

Mac, Windows, Linux

Click to try
Did you
AAC overtook
MP3 as
the most
audio codec
at the
of the century
when iPods and iTunes
were all the rage!

How to recover a bad audio recording?

AAC Repair Techniques

Repairing raw AAC data requires that each frame is identified, and then re-indexed or rewrapped into a playable container format. The hardest part is to identify AAC frames, since they don't have a header and have a variable length. Below we present 3 methods of increasing complexity, that produce respectively audible audio, audio with glitches, and good audio.

Pattern matching: This is an empirical method that doesn't try to validate AAC by the coding rules, but by patterns observed in the bitstream. Pattern matching uses bits matching, block lengths filters, ... With this simple technique, audio becomes audible, but quality is not good.

Surface decoding: This method decodes the beginning of an alleged AAC frame to validate it. It can check that important parameters — gain, maxsfb, frame size and termination — have coherent values. It achieves a good result, but not perfect, with one fault every 500 frames. We describe this technique in detail below...

Decode-Validate: This method, introduced in 2009, is giving near-perfect results. It uses a AAC decoder to validate alleged AAC frames. Frames that pass the test are then indexed and wrapped into the repaired M4A audio file.

Guidelines for parsing an AAC bitstream with "Surface decoding"

AAC uses variable-length blocks that are difficult to parse and identify.

In most common case, stereo LC AAC, we'll have the following bitstream:

[0x21  ][0x1b  ]
CPE |  ||| ics shape
    |  ||window sequence
    |  ||always 0
    |  common window
    element instance tag

  • If common window is 0, we have a Multiple Window (see below)
  • If window sequence (2 bits) is 2, we have a "EIGHT_SHORT_SEQUENCE" (see below)

Otherwise, the common case continues like this:

[0x21  ][0x1b  ][0xd4  ][0x4d  ]
              |   ||  gain (8 bits)
              |   |mask (2 bits)
              |   predictor (1 bit)
              maxsfb (6 bits)

maxsfb must be between 0 and the value from this table:

    12                      41          >96 kHz
    12                      47          >64
    14                      49          >48
    15                      51          >32
    15                      47          >24
    15                      43          >16
    15                      40          >8

It's common in a given file to only see two maxsfb values: one for EIGHT-SHORT-SEQUENCE, one for the rest of blocks. maxsfb value is usually close to or equal to the maximum of the table.

  • Predictor should always be 0.
  • If mask (2 bits) is equal to 1, then between mask and gain we insert maxsfb bits.
    In EIGHT_SHORT_SEQUENCE case, this value is multiplied by the number of windows.
  • Gain is usually between 100 and 200, and usually does not vary a lot in a given file.

After gain, we have the scale factor data (sequence of 4 and 5 bits):

[0x21  ][0x1b  ][0xd4  ][0x4d  ][0x05  ][0x20  ][0x25  ][0x01  ]
                             0,0  +1  0,1  +16 0,2  +5  0,3  +2
                                            17	    22       24

[0x09  ][0x8a  ][0x22  ][0x40  ][0x20  ]
 0,4  +6  0,5  +9  0,6  +4  0,7  +4
      30       39       43       47

We verify that after several sequences, summing the 5 bits increments, we arrive exactly on maxsfb (47 in this case).
Note that 5 bits increments should never be 0, and the 31 value triggers a new reading of 5 bits (example: 31, 5 gives 36)


windows sequence is always 10 (2) in eight-short-sequence frames.

[0x21  ][0x46  ][0xbd  ][0x65  ][0xAE  ][0x2c  ][0x26  ][0x6e  ]
         -/ ---/------/-/-------/---/--/---/--/---/--/---/--/
  always 10	  |   |    | gain(8) 0,0  6 1,0 6  2,0 +1 2,1 +5
              |   |    mask                         1      6
              |   scale factor grouping (7 bits)
              maxsfb (4 bits)

Note that here maxsfb is 6. Scale factor grouping with 2 zeros tells that we have 3 groups. Therefore, we have 3 sequences of alternate 4 and 3 bits that sum exactly 6.

Multiple Windows

This block has a different layout with 2 consecutive sets of data.

[0x20  ][gain  ][0x    ][0x4d  ]
                || |   |  predictor
                || |   maxsfb
                || shape
                |window sequence
         always 0

Just after predictor, we have the scale factor data (sequence of 4 and 5 bits).

Multiple Windows and EIGHT-SHORT-SEQUENCE

This combination is possible, and has the following layout:

[0x20  ][gain  ][0x4d  ][0xe6  ][0x1f  ]
                || | |  grouping
                || | maxsfb (4 bits)
                || shape
                |window sequence=2
         always 0

Just after grouping, scale factor data starts (sequence of 4 and 3 bits)

Degenerated block

You can find very short blocks with no data:

[0x20  ][0x99  ][0x00  ][0x02  ][0x64  ][0x00  ][0x0e  ]
CPE     -------/    -----/    -------/    -----/    END
           gain   maxsfb=0       gain   maxsfb=0

Note the layout of the two windows (second window starts with gain)

Degenerated block with padding

You can find blocks that appear normal in size but that contain no data:

[0x20  ][0x68  ][0x20  ][0x01  ][0xa0  ][0x80  ][0x0d  ][0xED  ]...68 bytes....
CPE      -------/    -----/||||-------/    -----/    FIL---/-------/  END
         gain      maxsfb=0||||  gain    maxsfb=0       type  length=0x68
                           |||no gain control data
                           ||no tns data
                           |no pulse data

AAC mono

Starts with this:

[0x00  ]

External links