HydrogenAudio

Lossy Audio Compression => AAC => Topic started by: thorrall on 2021-10-18 05:22:00

Title: Container for existing raw aac files?
Post by: thorrall on 2021-10-18 05:22:00
What is the easiest way to put existing raw LC-AAC files into a container such as m4a?  I have several hundred 256 kbps/48 bit depth  VBR aac stream recordings from an Internet radio station which I listen to frequently.  They are superb quality but there is no way I know to add metadata tags to raw aac files, so I would like to put them in a container without decoding the audio and then re-coding it, just adding metadata.  Maybe I'm being a little too fussy about not changing the audio in the process?  I do have software (NCH Switch) for converting aac files to m4a, but it messes with the audio in the process which I would like to avoid.
Title: Re: Container for existing raw aac files?
Post by: Porcus on 2021-10-18 07:21:08
ffmpeg is the to-go tool, and lots of other tools that do so are just front-ends to ffmpeg.

Quicker than typing, @sveakul posted this somewhere else: https://getmusicbee.com/forum/index.php?topic=23193.0
Title: Re: Container for existing raw aac files?
Post by: capma on 2021-10-18 11:32:52
MP4Creator is also a valid option.
Title: Re: Container for existing raw aac files?
Post by: jaybeee on 2021-10-18 12:21:30
As mentioned, ffmpeg will work, but I prefer to use MP4Box (https://github.com/gpac/gpac/wiki/MP4Box) (downloads (https://gpac.wp.imt.fr/downloads/)). I created a (windows) script a number of years ago to do this:

Code: [Select]
:: Name:     aac2m4a.cmd
:: Purpose:  Configures mp4box to package raw aac audio into m4a file
:: Author:   jaybeee
:: Revision: June 2021 - v2

@ECHO OFF

SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

:: variables begin with v

:: set name of this script without file extension
SET vMe=%~n0

:: set name of the parent directory where this script resides
SET vParent=%~dp0

:: set location of mp4box ** CHANGE ME **
SET vmp4box="C:\Program Files\GPAC\mp4box.exe"

:: call mp4box to place all raw aac files in current directory in m4a container and save to m4a directory
MKDIR m4a
FOR %%f IN (%*) DO %vmp4box% -add %%f "m4a\%%~nf.m4a" -new

:: if you prefer to process the entire directory, then uncomment below command (remove ::), making sure to comment the above FOR command
::FOR %%f IN ("*.aac") DO %vmp4box% -add "%%f" "m4a\%%~nf.m4a" -new

:: Finish
ECHO Finished m4a creation

:: pause can be used to view the extraction details
PAUSE

:END
ENDLOCAL
ECHO ON
@EXIT /B 0

Copy and paste the above into a text file and rename it aac2m4a.cmd.
Then drag and drop the aac file(s) onto the aac2m4a.cmd file and they'll be individually (losslessly) remuxed into a m4a container and placed into a m4a directory.
Or, as you can see from the script, you can process an entire directory by double-clicking the aac2m4a.cmd after having made the changes to the script (uncomment one command and comment the other).

Simple but effective.
Title: Re: Container for existing raw aac files?
Post by: imacguru on 2022-03-21 05:21:27
What is the easiest way to put existing raw LC-AAC files into a container such as m4a?  I have several hundred 256 kbps/48 bit depth  VBR aac stream recordings from an Internet radio station which I listen to frequently.  They are superb quality but there is no way I know to add metadata tags to raw aac files, so I would like to put them in a container without decoding the audio and then re-coding it, just adding metadata.  Maybe I'm being a little too fussy about not changing the audio in the process?  I do have software (NCH Switch) for converting aac files to m4a, but it messes with the audio in the process which I would like to avoid.


Hi Thorrall! If you are referring to files with the .aac filename extension as "raw LC-AAC" files that's not what they are. They are ADTS stream files. The best way to convert them to m4a is with ffmpeg. Here is a sample conversion that includes using the appropriate filter to convert ADTS to AAC (m4a):

ffmpeg -i 1.aac -c copy -bsf:a aac_adtstoasc 1.m4a

That works great for me with AAC-LC files. It will also convert HE-AAC files but the resulting m4a will not have the proper settings to trigger HE-AAC playback. Recent versions of ffmpeg should automatically use the bitstream filter aac_adtstoasc so including that in the command is optional. In that case the command would be:

ffmpeg -i 1.aac -c copy 1.m4a

Cheers,
Phil
Title: Re: Container for existing raw aac files?
Post by: Porcus on 2022-03-21 06:08:52
The answers from four months ago accomplish this. And also jaybee's script can be altered to accommodate drag+drop ffmpeg'ing.
But please be careful about the phrase "convert", as it is commonly associated with transcoding.