HydrogenAudio

Lossy Audio Compression => AAC => AAC - General => Topic started by: kylezo on 2016-03-12 11:24:27

Title: Batch wrap AAC in mp4/m4a?
Post by: kylezo on 2016-03-12 11:24:27
Hey ya'll,

I have a bunch of aac I demuxed from some mp4 videos, and I want to get them over to m4a eventually to throw them into picard and get all my metadata on there and have them compatible with my devices. I have YAMB and Avanti but Avanti doesn't seem to have this functionality built in, and YAMB throws errors every time I try to mux the aac to m4a or mp4 (although really oddly sometimes I get a file output that sounds ok even when it says muxing failed). I was able to batch demux with Avanti very easily and smoothly but I'm stumped for the next step.

It is my understanding that this should be a trivial task with YAMB. Am I an idiot?
Title: Re: Batch wrap AAC in mp4/m4a?
Post by: [JAZ] on 2016-03-12 12:16:50
I don't have experience with any of those (in fact, not even with mp4box), but ffmpeg should be able to do so with this instruction:
(replace inputname and oputputname with the appropiate names/paths)
Code: [Select]
ffmpeg.exe -i inputname.aac -acodec copy -bsf:a aac_adtstoasc -vn outputname.m4a

For batch processing, you can create a batch script. On windows, it could be like this:

Code: [Select]
set thisdir=%1
For /R %thisdir% %%J IN (*.aac) do (
"path_to_ffmpeg"/ffmpeg.exe -v error -i "%%J" -acodec copy -bsf:a aac_adtstoasc -vn "%%J".m4a
)
Saving that code into a .cmd file, and dropping the directory folder over this file for processing should do it.
Title: Re: Batch wrap AAC in mp4/m4a?
Post by: kylezo on 2016-03-13 03:00:05
Ah, thanks, I read the entry for aac_adtstoasc but wasn't sure it was what I needed (you'll notice I'm using front end GUIs for everything, there's a reason for that, haha).

/e: had to wrap \ffmpeg.exe in quotes with the path, and change / to \, then it sort of worked. Except all the files end with .aac.m4a now, but I guess that's ok. Gonna do it again with mp4, didn't notice the script had it set to m4a, haha. First I need the .mp4s to put in picard to tag+metadata/cover art, then convert (aka rename) to m4a.

My script looks like this:

Code: [Select]
set thisdir=%1
For /R %thisdir% %%J IN (*.aac) do (
"path_to_ffmpeg\bin\ffmpeg.exe" -v error -i "%%J" -acodec copy -bsf:a aac_adtstoasc -vn "%%J".mp4
)
pause

How would I configure it to move processed files to a particular directory?
Title: Re: Batch wrap AAC in mp4/m4a?
Post by: oberon0470 on 2016-03-13 03:58:12
You could use this command line with mp4box.

mp4box.exe -add [aac file] -new [m4a or mp4 output file]
Title: Re: Batch wrap AAC in mp4/m4a?
Post by: kylezo on 2016-03-13 07:05:47
You could use this command line with mp4box.

mp4box.exe -add [aac file] -new [m4a or mp4 output file]

Thank you, I got this instead:

Code: [Select]
set thisdir=%1
set "new_directory=E:\MP4"
For /R %thisdir% %%J IN (*.aac) do (
"path_to_ffmpeg\bin\ffmpeg.exe" -v error -i "%%J" -acodec copy -bsf:a aac_adtstoasc -vn "%new_directory%\%%~nJ.mp4"
)
pause
Title: Re: Batch wrap AAC in mp4/m4a?
Post by: [JAZ] on 2016-03-13 11:43:46
How would I configure it to move processed files to a particular directory?

You have the name of the generated file in "%%J".mp4, as you found out. The command to move the file is
Code: [Select]
move "%%J".mp4  C:\mydir\

As for the ".aac.mp4" double extension, the "%%J" syntax allows for separating it in "name" and "extension", but in my tests i had problems on directories with spaces where the full-path syntax worked. Then I simply batch rename with another program.