HydrogenAudio

Lossy Audio Compression => AAC => Topic started by: airtas on 2022-04-01 18:14:40

Title: repair m4a header that displays not available track time?
Post by: airtas on 2022-04-01 18:14:40
Is there anyway to fix a m4a that the track time shows 0?
Some apps play the song others don't.

From what I read the header needs to be fixed?
Title: Re: repair m4a header that displays not available track time?
Post by: DVDdoug on 2022-04-01 20:22:50
There are a couple of tools for fixing MP3 but I don't know of any for M4A. 

But... M4A (=MP4 = AAC) is pretty-much immune to accumulated damage from multiple generations of re-compression so you could convert it to WAV and then re-compress to a new M4A.

If you're on Windows you can use TAudioConverter or Kabuu Audio Converter (and hopefully they will open the file).   You might not actually have to make the intermediate WAV file.  I don't know if these things will decompress-recompress or just make a straight copy if you "convert" to the same format.   There's also a chance that you'll loose (or alter) any metadata if you convert to WAV so you may have to re-enter it.

If you don't know the current bitrate you can use MediaInfoOnline (https://mediaarea.net/MediaInfoOnline).
Title: Re: repair m4a header that displays not available track time?
Post by: Octocontrabass on 2022-04-01 20:30:58
M4A is just another name for MP4, so I would try remuxing it with any tool that can mux MP4.

The go-to solution is ffmpeg, and the command to run would look something like this:

ffmpeg -i bad-file.m4a -c copy fixed-file.m4a

But I'll admit I'm not very familiar with ffmpeg, so I can't guarantee this is the correct command. (And running it requires understanding how to run CLI programs at least a little bit.)
Title: Re: repair m4a header that displays not available track time?
Post by: doccolinni on 2022-04-02 04:59:29
But... M4A (=MP4 = AAC) is pretty-much immune to accumulated damage from multiple generations of re-compression so you could convert it to WAV and then re-compress to a new M4A.

Uh... no?!

Unless there's something I'm not aware of, AAC, being a lossy format, does also suffer from generational loss. It might not be as bad as with MP3, but it still happens.
Title: Re: repair m4a header that displays not available track time?
Post by: Aleron Ives on 2022-04-02 06:17:22
Unless there's something I'm not aware of, AAC, being a lossy format, does also suffer from generational loss.
Some time ago, a member did a test where he encoded some audio to various lossy formats, then decoded the lossy files and encoded to the same lossy format 100 times in a row. The AAC version fared very well, whereas MP3 and other lossy formats were completely destroyed. His assertion was therefore that transcoding AAC one time was better than transcoding MP3 or Vorbis one time, but since the results of 100 transcodes cannot be directly compared to the results of one transcode, the experiment was dismissed as inconclusive and largely forgotten. I suspect that's what DVDdoug is referencing, though.
Title: Re: repair m4a header that displays not available track time?
Post by: john33 on 2022-04-02 08:47:28
You could try using ffmpeg to strip it to an aac file and repackage it as an m4a file:
ffmpeg -i in.m4a -acodec copy out.aac
ffmpeg -i in.aac -acodec copy -bsf:a aac_adtstoasc out.m4a

EDIT: You will lose any tagging info that was in the original file so you will need to redo that.
Title: Re: repair m4a header that displays not available track time?
Post by: DVDdoug on 2022-04-03 17:43:30
Quote
I suspect that's what DVDdoug is referencing, though.
Right...

Nine different audio encoders 100-pass recompression test (http://Nine different audio encoders 100-pass recompression test)
Quote
AAC is the clear winner by far. It is virtually unaffected by the number of passes. All other codecs had degraded sound quality increasing with the number of encoding passes, especially at low bitrates.

I've read that that was an AAC design goal and if you think about it, information is thrown-away during lossy compression but there is no reason that more "real information" has to be thrown-away if it's re-compressed again to the same bitrate.
Title: Re: repair m4a header that displays not available track time?
Post by: DVDdoug on 2022-04-03 17:46:22
If FFmpeg works without de-compressing & re-compressing, that's great!!!     But it's not the end of the world if you have to re-compress.

Quote
I suspect that's what DVDdoug is referencing, though.
Right...

Nine different audio encoders 100-pass recompression test (http://Nine different audio encoders 100-pass recompression test)
Quote
AAC is the clear winner by far. It is virtually unaffected by the number of passes. All other codecs had degraded sound quality increasing with the number of encoding passes, especially at low bitrates.

I've read that that was an AAC design goal and if you think about it, information is thrown-away during lossy compression but there is no reason that more "real information" has to be thrown-away if it's re-compressed again to the same bitrate.