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: More questions about AAC gapless (Read 6162 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

More questions about AAC gapless

Hello,

I want to add gapless AAC support to GStreamer. To that end, I looked into how gapless AAC is achieved. Here's where the confusion started.

I've read in various places (in this forum, and also in others like this doom9 thread) about encoder delays of 1024 and 2624 samples.
I only have ever seen 1024-sample delays with the AAC files I've tested. Curiously, there is no talk about a decoder delay. Is there none for AAC-LC?

My main questions are:

(1) How do I detect whether a file is FAAC or Nero encoded? The former uses 1024, the latter 2624 samples. From what I gathered, the name "Nero" is present inside the AAC file somewhere if it was Nero-encoded. If it wasn't, then there is simply nothing. Which means I have to always assume an encoder delay of 1024 samples unless I can detect that this AAC-LC file was encoded with Nero or iTunes (see below). Is this correct?
(2) iTunes AAC data always comes in .m4a files, correct? The m4a files (which are simply MP4 containers with one audio track) contain the iTunSMPB metadata, which in turn contain the exact delay & padding values. Are there raw/ADTS iTunes .aac files?

EDIT: typo (FLAC -> FAAC)

More questions about AAC gapless

Reply #1
FLAC is an entirely different codec, not sure what you think it has to do with AAC?



More questions about AAC gapless

Reply #4
Mmm... I don't really know if you need to know the codec.
I found this on a file encoded with NERO that i have:

sudta....ndrm..........Émeta......."hdlr........mdirappl.............›ilst...c----....mean....com.apple.iTunes....name....cdec.../data........ndaudio 1.3.3.0 / -br 64000 -lc...0©too...(data........Nero AAC codec / 1.3.3.0....chpl................C....ytags...]meta.......cdec......ndaudio 1.3.3.0 / -br 64000 -lc...tool......Nero AAC codec / 1.3.3.0....tseg....tshd........free

Said that, I think that you would maybe look at the source code of FAAD2. AFAIK, it was developed/extended by part of the NERO team , and I think it supports gapless decoding.


More questions about AAC gapless

Reply #6
(1) How do I detect whether a file is FAAC or Nero encoded? The former uses 1024, the latter 2624 samples. From what I gathered, the name "Nero" is present inside the AAC file somewhere if it was Nero-encoded. If it wasn't, then there is simply nothing. Which means I have to always assume an encoder delay of 1024 samples unless I can detect that this AAC-LC file was encoded with Nero or iTunes (see below). Is this correct?

No. There are other AAC encoders, and AAC file can easily be re-muxed (using ffmpeg or something), which means that all of metadata in the container can easily be lost and you cannot rely on it.
Basically, you shouldn't assume anything, you shouldn't "detect" encoder, and you should take care of encoder delay / padding only when they are found.

(2) iTunes AAC data always comes in .m4a files, correct? The m4a files (which are simply MP4 containers with one audio track) contain the iTunSMPB metadata, which in turn contain the exact delay & padding values. Are there raw/ADTS iTunes .aac files?

iTunes doesn't directly encode into ADTS. However, you can easily remux .m4a into ADTS.

More questions about AAC gapless

Reply #7
(1) How do I detect whether a file is FAAC or Nero encoded? The former uses 1024, the latter 2624 samples. From what I gathered, the name "Nero" is present inside the AAC file somewhere if it was Nero-encoded. If it wasn't, then there is simply nothing. Which means I have to always assume an encoder delay of 1024 samples unless I can detect that this AAC-LC file was encoded with Nero or iTunes (see below). Is this correct?

No. There are other AAC encoders, and AAC file can easily be re-muxed (using ffmpeg or something), which means that all of metadata in the container can easily be lost and you cannot rely on it.
Basically, you shouldn't assume anything, you shouldn't "detect" encoder, and you should take care of encoder delay / padding only when they are found.


What baffles me is that Foobar can play these AAC files properly. To be exact, they are AAC-LC .m4a files, but with no iTunSMPB metadata. Looking at the decoded data in an audio editor I see the first 1024 samples are padding samples. So perhaps Foobar does assume that the first 1024 samples in AAC-LC files are always padding samples, unless the iTunSMPB metadata is found.

More questions about AAC gapless

Reply #8
What baffles me is that Foobar can play these AAC files properly. To be exact, they are AAC-LC .m4a files, but with no iTunSMPB metadata.


Maybe they use the Nero method?