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: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding (Read 6668 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #1
You can convert using ffmpeg:

ffmpeg -i in.m4a -acodec copy out.aac


Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #2
Okay, so, I tried that command, and then put both the original and the output into Audacity to phase-cancel them to see if there are any differences, and the weird thing is that, besides having to sync them up since the output had a bit of silence at the start, was that that was not silence at all(!) I'm currently just blaming this on Audacity's (or rather, ffmpeg 2.3.something's) AAC/Part 14 decoder/muxer for maybe skipping a frame, and then it being magically recovered when being decoded/muxed as ADTS but I have no clue.

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #3
Quote
was not silence at all(!)
I have no explanation for that.  I would expect it to at-least mostly-cancel.   But it does have to aligned to the exact-sample.

AAC/MP4 is generally immune to accumulated damage so I wouldn't worry about re-encoding - Nine different audio encoders 100-pass recompression test.   "AAC is the clear winner by far. It is virtually unaffected by the number of passes."

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #4
Be careful with .aac files. I remember couple of years ago when I was force to use .aac that many players had problems with it.
Seeking was not working and duration was wrong + I am not sure if metadata is working.

The "best" solution is what John mentioned above - no quality loss.

I saw in the manual above that your device supports FLAC so another solution would be to decode .m4a files and convert them to FLAC.
No quality loss + everything should be working fine.

FLAC is obviously huge, so another not-so-great solution would be to convert everything into MP3.

gold plated toslink fan

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #5
I have uploaded some images showing a recreation of the project I was working in, but with some extras, notably the lossless/hi-res version of the same track. Keep in mind that the difference's peaks are normalized so you can actually see what's going on there, and also notice that the lossless syncs up with the beginning of the Part 14, not the ADTS, and I've also tried another track from the same album, and while the silence/desync at the beginning was still there, that time it was actually silent.
I've changed my hypothesis because of this as well: Since this is an Apple Digital Master, their own resampler was probably used, and through the conversion process the initial seekpoint/chapter for the start of the song was placed ever-so-slightly later than right at the start since those were just some random resampling errors, and that's why it didn't matter for the other track I've tried as well, as in that case it's just digital silence inbetween the tracks.

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #6
And to reply to a couple of the points people have raised here:
But it does have to aligned to the exact-sample.
I made sure to do that obviously.
Be careful with .aac files. I remember couple of years ago when I was force to use .aac that many players had problems with it.
Seeking was not working and duration was wrong + I am not sure if metadata is working.
The duration is wrong because there isn't really a way to properly gauge it as far as I'm aware—besides estimating it based on the current bitrate—and that obviously doesn't really work when it's not constant. As for the metadata, I believe fre:ac has some information on it:
X
...while it's not like my player didn't play them back—in fact, it seemed to only be able to play the files specifically with metadata(!), although that might just be because of me not naming my test tracks/directories something a bit more obvious, and, on second thought, based on how the dirs would be sorted alphabetically, I think it was actually the files without metadata—it didn't actually manage to read any of it. And while you could argue that you could pretty much have all the info needed for basic browsing in the file/folder names, this player doesn't tell you what those are unless it's actually reading from the file in the first place! Otherwise you only get a basic FOLDERn and a number for the current track in the folder... So I've actually not really made any point towards actually wanting metadata to actually work...
AAC/MP4 is generally immune to accumulated damage so I wouldn't worry about re-encoding - Nine different audio encoders 100-pass recompression test.   "AAC is the clear winner by far. It is virtually unaffected by the number of passes."
The "best" solution is what John mentioned above - no quality loss.

I saw in the manual above that your device supports FLAC so another solution would be to decode .m4a files and convert them to FLAC.
No quality loss + everything should be working fine.

FLAC is obviously huge, so another not-so-great solution would be to convert everything into MP3.
I feel like this would kinda be missing the point, if I wanted to just go through a complete re-encode, then I'd probably just use the lossless/hi-res tracks at that point, since I still have no clue about the actual quality of the Apple Digital Masters tracks (i.e. Is it actually clip-free versus the lossless and just heavily limited instead or does the waveform look like that only because actual headroom was allocated for resampling and encoding but the clipping from the lossless is still there?) The only version/master of this album that I would actively go against is the CD-quality lossless version, since, based on my second hypothesis on the ADM version, the headroom required for resampling and dithering was definitely not allocated, or, at least, not as much as it shoud've, or maybe they did the heavy limiting/clipping 2 separate times for the two lossless versions and then derived the ADM version from the hi-res one?

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #7
What!? Sorry, I got kinda lost in your post above. What exactly are you trying to achieve?

Do you really think that this "Apple Magic" makes music sound better?
gold plated toslink fan

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #8
and the weird thing is that, besides having to sync them up since the output had a bit of silence at the start, was that that was not silence at all(!)
I must misunderstand something. From the screenshots you posted it looks like it is silence (beside the beginning, of course).

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #9
and the weird thing is that, besides having to sync them up since the output had a bit of silence at the start, was that that was not silence at all(!)
I must misunderstand something. From the screenshots you posted it looks like it is silence (beside the beginning, of course).
That bit at the beginning was what I was talking about. Notice how it otherwise only matches up with the ADTS, although that one isn't peak-normalized at all.
What!? Sorry, I got kinda lost in your post above. What exactly are you trying to achieve?

Do you really think that this "Apple Magic" makes music sound better?

Resampling, dithering, and lossily encoding audio all require a little bit of headroom to prevent clipping. The point/shtick of Apple Digital Masters (Previously Mastered for iTunes) is to directly deliver the encoded album yourself, instead of sending in CD-quality lossless files for them to encode it, and therefore allows you to make sure that the album doesn't clip due to the former and latter proccess, and that the middle one is undergone entirely, since encoding your tracks as 24-bit or more without dither is a requirement, and it does help the encoder who can take in that input in being more efficient/better-quality and stuff. (See this brief)
To be fair, at least Spotify kinda just do it themselves nowadays, although it is automated and therefore really loud stuff might still get clipped but I have no clue. (See "Convert to WAV 44.1 kHz (keeping bit depth)." and "and leave 1 dB headroom for lossy encodings") After they removed the former they also introduced actual ITU BS.1770 as opposed to ReplayGain as you can see in the latter, but the main improvement in my opinion is that only the Loud preset has a limiter anymore—every other preset is just peak normalized when too loud instead—and the point of the Quiet preset now is only to allocate more headroom for the nomalization to sound more consistent when you can take the hit (i.e. anything with a dedicated amp that's actually plugged into the wall.)

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #10
I don't want to sound rude, but what you are talking about makes no sense.

Resampling requires headroom? What?
I guess you are talking about lowpass? Every normal resampler will apply lowpass. (Most people use SoX, including myself)

Dithering requires headroom? What?
You only use dithering when reducing bit depth.
Lossy formats don't have bit depth.
Most editing is done in 32-bit float.
"All" lossy encoders accept 32-bit float so no need for dithering.
At 24-bit you are not going to hear dithering at all.
At 16-bit you could hear dithering at very loud volume.

Lossy encoding requires headroom? True.
Need some headroom? Nice. Import in Audacity, normalize to -1.5dB., export as 32-bit float, encode to AAC, done.

You gotta realize that music companies/labels are here to make money. They give zero fu*** about final product.
I will bet you million dollars that 99% of "ADMs" are terrible sounding (very loud, no dynamic range...)
compared to original CD releases that you don't want to use.
gold plated toslink fan

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #11
Wow, that's quite a lot to unpack, here goes:
Resampling requires headroom? What?
I guess you are talking about lowpass? Every normal resampler will apply lowpass. (Most people use SoX, including myself)
Yes it does, or, more precisely that lowpass you mentioned does, and in fact, any lowpass does, including the one used in a lossy encoder, and the one that's part of a DAC or ADC.
Quote
Dithering requires headroom? What?
Yes it does, a very slight amount, but it does, and some software, like Audacity, seems to compensate for it automatically, whereas others, like foobar2000 seemingly don't, at least that one time I tried to encode 8-bit.
Quote
Lossy formats don't have bit depth.
Depends on the codec. I think some legitimately, all notably subband codecs, internally work at 16-bit, or at least if every encoder and decoder you can find only natively accepts up to 24-bit I think it's safe to assume, like with the ADPCM DTS or aptX (HD/Adaptive).
Quote
"All" lossy encoders accept 32-bit float so no need for dithering.
I guess I just miswrote when I said undergone and not forgone.
Also to tie into the earlier thing even for formats that most definitely don't internally have a bit depth, like the MDCT-based AC-3 and AAC might still have fixed-point encoders available for them, like the fixed-point AC-3 encoder included with ffmpeg, and fdk-aac respectively. That could be the reason why you wrote all in quotation marks though.
Quote
At 24-bit you are not going to hear dithering at all.
Because no single DAC or ADC can go that far down. (I guess I'm not disagreeing with/correcting myself/you at this point, just expanding on what you said, because it's pretty much true)
Quote
At 16-bit you could hear dithering at very loud volume.
Or with a bunch of headroom, I guess.
Quote
Lossy encoding requires headroom? True.
Need some headroom? Nice. Import in Audacity, normalize to -1.5dB., export as 32-bit float, encode to AAC, done.
That's what Apple's own utilities are for, (Ok, not just for that, they're also there to find clipping due to encoding/resampling including intra-sample clipping, presumably by upsampling using a resampler that has one of those lowpasses you told me don't require any extra headroom)
Quote
You gotta realize that music companies/labels are here to make money. They give zero fu*** about final product.
This is not some random artist that was eff'd over by getting the contract that gives the record label the most control over the artist, creative or otherwise. This artist specifically went out of the way to hire one person in particular to make more than one master and let them pick which one they liked the most.
Quote
I will bet you million dollars that 99% of "ADMs" are terrible sounding (very loud, no dynamic range...)
That is not what I was concerned about. I already knew that the record was heavily brickwalled. I was specifically wondering if the iTunes release could get rid of the clipping of the other versions, and that was what I speculated about.
Quote
compared to original CD releases that you don't want to use.
This is worded as if a different master is available on the original CD that people always insist is better, like that holy grail Japanese Sony version of The Dark Side of the Moon, to name an example that is, in my opinion personal preference, notably excluding the 2003 CD, which was probably mastered like that to specifically make you think that the SACD version sounds way better, although it seems to have failed at even that (see the top review, in which he ranks the 2003 CD above the first EMI master, stereo SACD, and the holy grail CD in dead last,) and to name a more dire example the 20th anniversary version of Nevermind, where you're legitimately better off with an original CD or alternatively the MFSL version...
But that's not the case here, again, see my speculation.

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #12
True. They do require headroom, minimal, but they still do.
It's just that when we talk about headroom, we think about peak normalization, the famous 1.5dB of headroom.
No need to nitpick about resampling and dithering.

I am talking about relevant lossy formats like Opus, AAC and MP3. They do not have bit depth.
Yes, that is exactly why I wrote "all", this is posted in AAC forum, I knew you will mention fdk.

But I still have no idea what you are trying to say...

First you were talking about car radio, now you want to know if these magical Apple files are clipping or not?

Quote
I was specifically wondering if the iTunes release could get rid of the clipping of the other versions, and that was what I speculated about.
The point/shtick of Apple Digital Masters (Previously Mastered for iTunes) is to directly deliver the encoded album yourself
This artist specifically went out of the way to hire one person in particular to make more than one master and let them pick which one they liked the most.

... but you just said that files are delivered by artists themself, what does Apple/iTunes have to do with this?
If it clips - blame the artist.

... or you are wondering about normal (non ADM) files? I just grabbed some from the interwebz, decoded into 32-bit float, and yes, they do clip.
gold plated toslink fan

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #13
Apple doesn't have anything to do with it, that's kinda the point of ADM, unless you understood that the mastering engineer/house is separate from the artist and Apple, what I was trying to to say is that they are on the side of the artist, and besides the record label, they're the ones who send the files in, otherwise, the only requirements are that the input is not 16-bit and that there isn't an excessive amount of clipping due to resampling/encoding, not necessarily because the input wasn't clipped in the first place, which was what I was trying to figure out and if therefore the ADM release would be superior in a way to the lossless version.
And just to reiterate my theories on what exactly happened with the versions/masters of this album:
since I still have no clue about the actual quality of the Apple Digital Masters tracks (i.e. Is it actually clip-free versus the lossless and just heavily limited instead or does the waveform look like that only because actual headroom was allocated for resampling and encoding but the clipping from the lossless is still there?) The only version/master of this album that I would actively go against is the CD-quality lossless version, since, based on my second hypothesis on the ADM version, the headroom required for resampling and dithering was definitely not allocated, or, at least, not as much as it shoud've, or maybe they did the heavy limiting/clipping 2 separate times for the two lossless versions and then derived the ADM version from the hi-res one?

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #14
About the original post:

The difference you see comes from the fact that probably for M4A, the decoding is removing the encoder delay, while on the aac one this is not cut out.

Encoders in MP3, MP4 and many other codecs have some buffers in order to know the signal before and after the part that they are analysing.  If the encoder delay is not removed, it also decodes this additional part of the buffer.

On an MP4 container, this information is stored. On AAC, this information is not available.

In other words, ffmpeg did losslessly remove the MP4 container and gave you the AAC stream. But the AAC stream does not have information for decoders/players to skip the decoder delay.


Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #15
The difference you see comes from the fact that probably for M4A, the decoding is removing the encoder delay, while on the aac one this is not cut out.
This, most likely.

Using foobar2000 with https://www.foobar2000.org/components/view/foo_bitcompare will probably return an offset and otherwise identical audio.

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #16

Am I correct that I should use ffmpeg -i -song.aac -acodec copy song.m4a

if I want to convert from a song.aac file to a new song.m4a file?

The answer is probably completely obvious to anyone familiar with command line utilities but unfortunately I'm not.  Also, maybe someone could suggest a GUI equivalent to ffmpeg?

Thanks
__________________________________________________________

You can convert using ffmpeg:

ffmpeg -i in.m4a -acodec copy out.aac



Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #17
[...] maybe someone could suggest a GUI equivalent to ffmpeg?

https://ffmpeg-batch.sourceforge.io/

default parameters ("-c copy") is equivalent to "-codec copy" and covers both audio and video codecs
just enter the proper extension into the "Format" box
drag your files in and hit one of those encoding buttons

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #18
- Nine different audio encoders 100-pass recompression test.   "AAC is the clear winner by far. It is virtually unaffected by the number of passes."
Create Wednesday, March 20, 2013. I don't think the old post it's still relevant.
There may be a methodological flaw cause each lossy codec has a different encoding algorithm.

"Have you ever wondered how different codecs are affected by re-encoding / re-compressing? Of course, recompressing audio is a bad idea, but sometimes can't be avoided."
This is a double standard no sense.
I don't want to sound rude, but what you are talking about makes no sense.

Lossy encoding requires headroom? True.
Need some headroom? Nice. Import in Audacity, normalize to -1.5dB., export as 32-bit float, encode to AAC, done.
Suppose you want to convert a 24/96 file to 16/44.1...
1. Convert to a higher bit-depth (e.g. 32/64-bit float)
2. Resample to 44.1k
3. If the resampling process introduced sample values beyond 1.0 (0dBFS), apply a negative gain
4. Dither
5. Convert to 16-bit

Intermediate steps are all done in the highest possible bit-depth supported by the application's internal data path to minimize quantization error, and to prevent clipping.
https://hydrogenaud.io/index.php?topic=121633.msg1004047#msg1004047
Opus 96-192Kbps and Aac-lc 96-128Kbps
Source 32bit floating point is fine don't need dithering (dB noise -758dBFS that's a lot)
Source Fixed Point aka Integer should use dithering to prevent truncation distortion
Source is RAW

 

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #19
@amariami
Let's see an example you previously posted, with the file "32_bit_float.WAV"
https://www.sounddevices.com/sample-32-bit-float-and-24-bit-fixed-wav-files/
You can see that both opus and vorbis showed no clipping, aac clipped several dBs, and mp3 clipped a lot.
X
Without knowing the used codecs and their versions/variants, there are no definite answers about clipping or not, and threshold of clipping.

On the other hand, for plain integer PCM it is impossible to go beyond 0dBFS. Since your quoted text of mine is not originated from a lossy codec discussion, I have to point this out in order to make it clear.

Re: Convert MPEG-4 Part 14 (.m4a) to MPEG-4 Part 3 ADTS (.aac) without re-encoding

Reply #20
@amariami
On the other hand, for plain integer PCM it is impossible to go beyond 0dBFS. Since your quoted text of mine is not originated from a lossy codec discussion, I have to point this out in order to make it clear.
yep thanks man I just showing your quoted and Markuza97 to @DVDdoug
Opus 96-192Kbps and Aac-lc 96-128Kbps
Source 32bit floating point is fine don't need dithering (dB noise -758dBFS that's a lot)
Source Fixed Point aka Integer should use dithering to prevent truncation distortion
Source is RAW