Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Patching sample rate in AAC files? (Read 3717 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Patching sample rate in AAC files?

Hi,

My personal audio player seems to have a little bug: stereo (HE-)AAC files play fine, but mono ones play at double the correct speed!

I'm using ISO AAC files, not MPEG-4. I can think of two workarounds for this:
1. Before encoding, convert the source mono WAV file to stereo, where both channels are exactly the same, and create a stereo AAC file where both channels are the same (if that's possible). That would probably result in larger AAC files.
2. After encoding, patch the sampling rate specified in the AAC file to half the actual rate, e.g. to 22050Hz in the case of 44.1kHz audio. Then the player will hopefully play the mono file at the correct speed.

I'd like to experiment with the second workaround. Is the sampling rate specified at only one point in an ISO AAC file? Or is it repeated in every audio frame (or whatever the correct term is)? If the former, where can I get info on the AAC file header layout, apart from the (expensive) ISO standard document?


-- M

Patching sample rate in AAC files?

Reply #1
(1) Would work fine. The encoders are generally "smart" enough to figure that L=R and spend almost 0 bytes encoding the extra channel.

Samplerate is speficied in the header for each frame (ADTS), or once for the whole file (ADIF, MP4). ADIF and ADTS descriptions are findable on the net.

Patching sample rate in AAC files?

Reply #2
Quote
(1) Would work fine. The encoders are generally "smart" enough to figure that L=R and spend almost 0 bytes encoding the extra channel.

Samplerate is speficied in the header for each frame (ADTS), or once for the whole file (ADIF, MP4). ADIF and ADTS descriptions are findable on the net.


Thanks. I found some info about ADIF and ADTS on the audiocoding.com wiki.

Are there any free tools to convert ADTS<->ADIF (or ADTS->MP4 and MP4->ADIF)? Or to convert ADTS to a raw headerless stream? Apart from curiosity to see whether my player works with ADIF files, they are smaller than ADTS.

If I can convert ADTS to ADIF, then I can easily patch the sampling rate in the header of mono files. (Useful if I only have a mono AAC file and no access to the uncompressed source - and no desire to write a program to parse an entire ADTS file changing the frame headers.)


-- M

Patching sample rate in AAC files?

Reply #3
You might run into troubles if you change the sampling rate. AAC makes use of a sampling rate specific partition of the spectrum into scalefactor bands. Changing the sampling rate could render the AAC stream useless (I'm not 100% sure).

The best option seems to be to transcode your file from mono to stereo. In theory this could be done losslessly. But there's probably no software yet able to do this.

Sebi