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: Is AAC/M4A truly gapless, like lossless files? (Read 13862 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Is AAC/M4A truly gapless, like lossless files?

I want to convert a significant collection of lossless files to lossy.  I'll be keeping the lossless files for archiving purposes and I plan to only play the lossy files for listening.

So I found this article on HA, which explains why MP3 had problems with introducing gaps in between tunes.  I experienced this firsthand way back in the day when I tried to re-encode lossless files (and CDs) into MP3s and suddenly had audible gaps in my live albums and classical CDs which originally had seamless segues between songs.  (Some albums, like opera, need to be seamless for the entire recording ... a dozen or more tracks that are all seamlessly connected as one concert performance.)

http://wiki.hydrogenaud.io/index.php?title=Gapless_playback

So in the same articles near the bottom, it says the key to avoiding unwanted gaps is to encode as follows:

AAC in MP4 encoded with Nero Digital from Nero AG can be gapless with foobar2000.
AAC in MP4 encoded with iTunes 7.0 can be gapless with iTunes 7.0 and latest foobar2000.


I don't want to use Foobar2000 and I don't want to use iTunes.  I'm a Mac user and want to use XLD exclusively to convert FLACs and ALACs to high quality lossy M4A.

Is there any possibility that unwanted gaps can be introduced when re-encoding lossless FLACs and ALACs to M4A using XLD?

XLD is not mentioned in the article, but Foobar2000 and iTunes are ... so that leaves me wondering if there is something potentially wrong with XLD (and other encoders) that could cause it to create the same unwanted gaps I experienced back in the day when I was encoding to MP3 using some primitive software.

Does anyone know for certain if I'm 100% safe using XLD to convert classical and live-concert lossless album files to M4A?

Is AAC/M4A now a perfectly reliable codec for gapless albums?






Re: Is AAC/M4A truly gapless, like lossless files?

Reply #1
XLD is not an encoder; it won't have any bearing on the situation.  The question is which encoder is XLD configured to use and whether your player can play those tracks gaplessly.

FWIW, I don't have a single mp3 that cannot be played back gaplessly in a capable player (hardware or software).  Yes, it is possible for there to be a significant discontinuity in level from the first same of the current track and the last sample of the track preceding it, but that has yet to be a problem for me.  The same can happen with just about any of the other lossy formats.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #2
XLD is not an encoder; it won't have any bearing on the situation.  The question is which encoder is XLD configured to use and whether your player can play those tracks gaplessly.

Dang, Greynol.  I have no way of understanding what you wrote here.  It must be a matter of terminology and vocabulary.  XLD is a piece of software that transcodes one file format to another.  FLAC to M4A ... ALAC to MP3 ... whatever.  In my mind, that makes it an "encoder".  Maybe I'm not using the term correctly.

All I want to do is use XLD to convert either a single whole-album FLAC (with cue) to M4A ... or convert a folder of FLAC tunes with gap info inherent in the tracks to M4A.  I plan to do the same with some ALACs and APEs, but that's much less often.  The FLAC to M4A plan is the bulk of it.

So in the very distant past, I transcoded some "continual" (classical/live) CDs to MP3 and found gaps in between the newly-created tracks, which made the resulting album-folder unusable.  An audible gap in a segue'd series of tracks is enough to cause me to delete the whole album and just go back and listen to the source recording I used (the CD or the FLAC).

But the goal here is to do this correctly this time ... I want to take my lossless files, convert them to M4A, and listen to them mostly in iTunes ... without ever hearing an unwanted gap.

If you're still interested in helping/educating me, please rephrase your first two sentences so they might make sense to me.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #3
XLD is a snazzy front-end that uses one or two other third-party encoders/decoders (AKA codecs) to do its dirty work (same is true for foobar2000; Apple uses their own codecs).  XLD itself is not an encoder.

You use iTunes for playback.  Now we can get somewhere.  You now need to research which aac encoders play gaplessly in iTunes and how you can configure XLD to use one of them.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #4
Are you saying that I actually configure XLD to use a third-party encoder?  I downloaded XLD some time ago ... have kept it updated ... and never knew anything about it "pointing" to other software that actually does the work.  So you're saying that there is a pref (or whatever) in XLD somewhere that allows me to configure it to use an encoder other than what is resident in the thing when I downloaded it?

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #5
According to its home page XLD uses the official QuickTime codec as does iTunes:

http://tmkk.undo.jp/xld/index_e.html

Have you tried it to see if it does what you want?

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #6
I have verified on a past occasion that XLD produces gapless files when using the supplied "MPEG-4 AAC" encoder option, with whichever settings you wish. They will play gaplessly in iTunes, Cog, and any other player which uses the CoreAudio framework for MPEG-4/AAC playback.

Incidentally, if you happen to roll with a beta of macOS Sierra, you'll need the test version listed in this ticket, or else none of the plug-ins will load, and it will only support a handful of raw formats.

The compile-for-yourself-because-distribution-is-apparently-a-legal-gray-area plugin based on libfdk_aac is also gapless, after I contributed reports to make it so, based on hard coded parameters that apparently don't vary from one standard encoder to another.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #7
I have verified on a past occasion that XLD produces gapless files when using the supplied "MPEG-4 AAC" encoder option, with whichever settings you wish. They will play gaplessly in iTunes, Cog, and any other player which uses the CoreAudio framework for MPEG-4/AAC playback.

Very cool, kode54.  I won't even ask how you verified this (although if you have a link to that discussion, I would certainly read it).

Now I'm learning though that the new transcodes actually might play differently depending on which player I use?  I had no idea that this happens.  I thought a music file was a music file.  I didn't know two different programs might play the same file differently. 

Yes, I plan to use iTunes the most.  In fact the reason I'm doing this at all is because I've used VOX for years but I'm tired of not having an album-art menu system.  That's (mostly) unique to iTunes and is (for me) more conducive to opening a file and listening than dragging a cue file onto VOX.  I wish there was something other than iTunes for this purpose, but on a Mac, there seem to be no other options for clicking on an album from the cover art.

I guess I'll have no way of knowing if these reliable iTunes-friendly lossy transcodes will work just as well when it comes time to start using yet another program for playback.  But your assurance that you've found XLD to transcode reliably (ie, no unwanted gaps, ever) is enough to get me started with this project.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #8
According to its home page XLD uses the official QuickTime codec as does iTunes
Right, QAAC and XLD are done by the same guy; I completely forgot.  Maybe it was because one program is for Mac (which I don't use, if that wasn't obvious) and one for Windows.

As a front-end, XLD would be broken if it created gapped files passing data between gapless codecs.  This would be the absolute last place to check if gapless playback was an issue.

The reason for tip-toeing around iTunes is that it has to scan files for data so it can determine how to treat them for gapless playback within iTunes.  From what I have read this hasn't exactly been smooth sailing for all of the various non-QuickTime AAC encodes.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #9
Now I'm learning though that the new transcodes actually might play differently depending on which player I use?  I had no idea that this happens.  I thought a music file was a music file.  I didn't know two different programs might play the same file differently. 

This is going to be very imprecise, but hopefully it explains what is going on:

The "audio part" of the music file is "the same for every player" yes, but not all playback-related information is in the "audio part" (specified by the codec, the audio encoding/decoding format and the stream of audio packets that form what I loosely refer to as "audio part").
Why not? Because it was not specified in the codec in the first place, so one had to add it a different way in order not to break the file.

So if iTunes adds a tag that says "When playing this file, show a slideshow about how to teach your children to worship Apple and swear to never touch an Android device", you cannot assume that a different player will honor the tag and do the same thing. It is not part of the codec (the audio coding/decoding specification). If one would put this into the actual audio stream, it would no longer be an MP3 / an AAC.

Unfortunately, gaplessness is one of those features that are not part of the MP3/AAC audio specification. That is a "hack" which a compliant player need not honor. Although the Xing/Lame headers that specify how to achieve gaplessness in MP3 are, dare I say, widely supported.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #10
A thoroughly adequate explanation, Porcus.  (Read:  I was able to grasp it.)  Thanks for explaining that in terms I could understand.

Unfortunately, gaplessness is one of those features that are not part of the MP3/AAC audio specification. That is a "hack" which a compliant player need not honor.

It's hard to believe the industry evolved that way.  Gaplessness is critical to a fair number of recordings.  But, there it is.  It's not part of the AAC audio specification.




Re: Is AAC/M4A truly gapless, like lossless files?

Reply #11
These technologies were developed for and partially by companies targeting the a/v broadcast industries. Pretty much anything related to consumer playback of files/homemade rips on a computer was someone else's problem. If you had asked the developers about gapless playback of separate MPEG streams, they would have just replied that was outside the scope of their concern. "If your customer/user wants to hear two songs in a row and need them to be no risk of a break in continuity, why would you encode and deliver them as separate streams with metadata attached to each one? Just send them one stream with both songs encoded together, and send the metadata down another pipe altogether. Surely someone in the industry will solve that problem with a robust file format and standards for players, with appropriate DRM on everything... now stop bothering us, pirate."

This of course is the engineer's fallacy... they are so often blissfully unaware of the fact that "good enough" cobbled-together solutions will be adopted more readily than their perfectly thought-out, endlessly planned systems. The manner in which gapless playback (of MPEG streams) was achieved in software players to date has been good enough for most people who care about it, so a better, more universal solution has not been developed. Same can be said of the manner in which metadata is attached to MP3 files. ID3 is a total hack that was just popular enough to be widely supported. LAME tags and VBR headers as well. MP4/AAC recognized and addressed these problems somewhat, but gapless playback tagging and playback was not fully solved nor mandated from the outset.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #12
Unfortunately, gaplessness is one of those features that are not part of the MP3/AAC audio specification. That is a "hack" which a compliant player need not honor.

It's hard to believe the industry evolved that way.  Gaplessness is critical to a fair number of recordings.  But, there it is.  It's not part of the AAC audio specification.


Nevertheless, a pretty accurate summary.  There are plenty of lossy codecs (and lossless) that are inherently gapless, but AAC isn't one of them.  One of the reasons my dalliance with AAC was extremely short was that depending on the source of the tracks, I might get gapless playback with one player, not gapless with another, or vice versa.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #13
Very cool, kode54.  I won't even ask how you verified this (although if you have a link to that discussion, I would certainly read it).
I can post verification that I'll probably have to regenerate here. It involved using a couple of chopped audio files and encoding them, then playing the resulting files, which otherwise would have had an obvious gap.

Let me see if I can find them again. Aha, here you go:

https://f.losno.co/gapless_test.tar
https://f.losno.co/gapless_test_2.tar - eventually LOUD

Both sets courtesy of @Case I think. And at least in Cog, you'll need your sound output to match the files for set 2 to be gapless, since I still have not worked out running the same resampler instance across multiple files. It still does like it originally was written, to resample each individual file.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #14
There are plenty of lossy codecs (and lossless) that are inherently gapless, but AAC isn't one of them.  One of the reasons my dalliance with AAC was extremely short was that depending on the source of the tracks, I might get gapless playback with one player, not gapless with another, or vice versa.

As I was researching AAC, the phrase that kept coming up was "the successor to MP3".

Wouldn't the problem you're describing here, this issue of gaplessness not being inherent in the music file, be sort of a dealbreaker and a serious knock against AAC?  That hardly seems to me to be the next generation, moving past MP3.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #15
As far as I understand, AAC/MP3/Vorbis/etc codecs cannot be gapless themselves. Gaplessness is achieved via special metadata in a container (MP4/MP3/OGG/etc).

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #16
There are plenty of lossy codecs (and lossless) that are inherently gapless, but AAC isn't one of them.  One of the reasons my dalliance with AAC was extremely short was that depending on the source of the tracks, I might get gapless playback with one player, not gapless with another, or vice versa.

As I was researching AAC, the phrase that kept coming up was "the successor to MP3".

Wouldn't the problem you're describing here, this issue of gaplessness not being inherent in the music file, be sort of a dealbreaker and a serious knock against AAC?

I don't think the MPEG people really care about gaplessness, so from their point of view, no.  Gapless works fairly well in AAC though, at least with Apple devices.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #17
Well is "gapless" more than a matter of granularity? Surely if you want to nitpick, a format with a given samplerate cannot be gapless below one sample, but can e.g. FLAC cut gaplessly with lower granularity than its minimum block size of 16 samples?

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #18


Voila. Note the "add gapless information for iTunes" option.

I  have never had an issue with AAC gapless encoding using XLD or dBPoweramp. Where you should really worry about gaps is with your rips.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #19
It's hard to believe the industry evolved that way.  Gaplessness is critical to a fair number of recordings. 

You could of course always encode the entire thing as one file, and use cuesheets to set track marks. Inconvenient for portable use, I'd say. But really, the MP3 file format sucks. With AAC there became a different distinction between the codec and the container.

This is kind of a digression, but when the CD format was designed, it was not supposed to be gapless between 'tracks'. That was what index marks were supposed to do. But the industry did not like that design, so they just started to use tracks. And put music in the gap between the tracks. And you got all sorts of "I get two seconds of silence in my music when I burn CDs!" issues posted all over the internet. Not so much anymore, because the "gapless hack" has taken over and is honored by any sensible CD burning application ... I think. Or maybe just because nobody burns CDs anymore.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #20

Voila. Note the "add gapless information for iTunes" option.

Wouldn't a person want to have that ticked on by default all the time?

Maybe I don't quite understand the logic ... but if the source lossless album-file or album-folder has gapless tracks, then ticking this box would transfer the gapless info into the transcoded AAC.

But if the source lossless album-file or album-folder had songs with normal gaps ... then even if I had this box ticked off, that gap info would *also* be brought over to the transcoded AAC, no?

So why not have this box ticked off all the time and for every album I transcode, gapless or not?

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #21
This is kind of a digression, but when the CD format was designed, it was not supposed to be gapless between 'tracks'. That was what index marks were supposed to do. But the industry did not like that design, so they just started to use tracks. And put music in the gap between the tracks. And you got all sorts of "I get two seconds of silence in my music when I burn CDs!" issues posted all over the internet. Not so much anymore, because the "gapless hack" has taken over and is honored by any sensible CD burning application ... I think. Or maybe just because nobody burns CDs anymore.
About a decade had passed between the average consumer being able to buy a CD and the average consumer being able to burn a CD.  My first burning program was designed to work with Windows 95.  It came bundled with my first SCSI burner.  It could burn gapless CDs from individual tracks just fine.  DAO being a "hack" is news to me.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #22
As far as I understand, AAC/MP3/Vorbis/etc codecs cannot be gapless themselves. Gaplessness is achieved via special metadata in a container (MP4/MP3/OGG/etc).
I don't think this is right.  Vorbis handling of inter-track "gaps" is explicitly defined in the codec, so they are eliminated during playback with any compliant decoder.  There is no need for metadata to achieve this,  I don't think it is even correct to say that is down to the container, although that may just be semantics since there's no such thing as Vorbis without a container.  There is a potential artefact (due to the lossy encoding) even on a completely gapless track transition since the last frame of one track and the first of the next are not crosslapped the way that frames within a track are.

Vorbis isn't the only codec to do this sort of thing.  I'd have said, off the top of my head, that most of them do it and AAC/MP3 was the exception, but I don't know.

P.S.  I looked at where the track start and end information is stored and I guess it is part of Ogg rather than part of Vorbis.  Anyone know what happens in Matroska/webm?

 

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #23
Wouldn't a person want to have that ticked on by default all the time?
It is ticked on by default. It's there in case, for some weird reason, you'd like to disable it.

Re: Is AAC/M4A truly gapless, like lossless files?

Reply #24
Wouldn't a person want to have that ticked on by default all the time?
It is ticked on by default. It's there in case, for some weird reason, you'd like to disable it.

I noticed that it is ticked on by default, kode54.  My poorly phrased question was why someone *would* disable it...?