Jump to content

Welcome to AnimePassion
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. If you already have an account, login here - otherwise create an account for free today!
Photo

Batch file to auto-convert audio


  • Please log in to reply
12 replies to this topic

#1
FoxesDen

FoxesDen

    Red Ribbon Army

  • VIP
  • 563 posts
  • 23 thanks
  • Local time: 09:12 PM
  • LocationGreat White North
I wrote a general purpose batch script to automatically convert audio to other formats using Eac3to. This is mainly useful for converting lossless audio to lossy.

You need Eac3to, and if want to convert to AAC you need the Nero AAC Encoder. If you don't already have it I've uploaded neroAacEnc.exe to FileFactory. Just extract the archive and place neroAacEnc.exe in the same folder as eac3to.exe.

Open the Spoiler and copy the contents into Notepad. Save the file as ConvertAudio.bat (or whatever you want to call it as long as it's saved as a .bat file.) Read the comments in the batch file and follow their instructions. You need to set the location of your eac3to, the format you wish to convert to, and the track numbers and desired bitrates for the audio tracks. Be sure to read extra included notes on how to deal with commentary audio tracks. When editing batch files be sure to right-click them and select "Edit", or else you're going to wind up executing it.

With that done, just drop the batch file into the same folder as your .mkv files and double-click it to run it. It will display detailed progress in a cmd window as it runs, ending with a "Press any key to continue..." message. The converted audio tracks will be placed in a "tracks" folder, ready to be dragged into MKVmerge for remuxing. Note that .m4a files are AAC audio and all tools will recognize them as such.

Spoiler

I originally wrote this to convert the audio for Raizel's encode of "High School DxD", so you will see it defaults with episodes 01 and 07 containing Commentary audio tracks.

Anybody who's done any scripting shouldn't have any difficulties using this. It's pretty straight forward. You don't need to know how to write scripts to change the settings to what you want.

As a note I just want to say, Windows scripting is the most horrid, disgusting, kludgy mess I've ever had the displeasure of working with. Something as basic as:

if ((x == 1) || (x == 7)) then...

is completely beyond it. Their idea of subroutines returning results is to put them into global variables. But then subroutines themselves are a hack. "exit /b" is how you return from subroutine?! Variable scopes are turned upside down inside nested layers, and they have all kinds of hacks for accommodating such things, but then they always manage to break something else. It's all just hack after hack, kludge on top of kludge. I've worked with many different scripting systems and programming languages over my extensive career, but have never before encountered anything as messy as Windows scripting.
ztor6.jpg

Thanked by 1 Member:
DeathTheKid

#2
Cman21

Cman21

    /)*(\ ^_^

  • Administrators
  • 2,440 posts
  • 257 thanks
  • Local time: 09:12 PM
very interesting. but what if i already extracted all the audio into its own folder? Simply change the extention to .flac for example and it will still work i presume?

#3
FoxesDen

FoxesDen

    Red Ribbon Army

  • VIP
  • 563 posts
  • 23 thanks
  • Local time: 09:12 PM
  • LocationGreat White North
Well this batch file is meant for use with dual audio files with optional commentary. (ie: either 2 or 3 audio tracks.) If you just want to run through a folder of flac files to convert you can do something much simpler such as this:
@echo off
for %%I in ("*.flac") do "C:\eac3to\eac3to.exe" "%%~nxI" "%%~nI.ac3" -640 -log=NUL
pause
Just set the correct path to your eac3to.exe, replace .ac3 with .m4a if you want AAC files, and change the -640 to whatever bitrate you want. This will just dump the new track conversions in the same folder as the originals.

If you want the newly converted tracks to be dumped into a separate "tracks" folder then use this:
@echo off
if not exist "tracks" mkdir "tracks"
for %%I in ("*.flac") do "C:\eac3to\eac3to.exe" "%%~nxI" "tracks\%%~nI.ac3" -640 -log=NUL
pause

ztor6.jpg

#4
Cman21

Cman21

    /)*(\ ^_^

  • Administrators
  • 2,440 posts
  • 257 thanks
  • Local time: 09:12 PM
lol it is much simpler >.<

#5
FoxesDen

FoxesDen

    Red Ribbon Army

  • VIP
  • 563 posts
  • 23 thanks
  • Local time: 09:12 PM
  • LocationGreat White North
Just a heads ups that I made a slight change to the batch file and my posts. Although normally Eac3to will automatically create a "tracks" folder if one didn't already exist (since I specified one in the output path), I discovered it won't when m4a (aac) is specified. Control is passed to the Nero AAC Encoder, and unlike Eac3to, it will just return an error if the folder didn't already exist.

I added the following line to the batch file:

if not exist "tracks" mkdir "tracks"
ztor6.jpg

#6
skycamefalling84

skycamefalling84

    Mushi

  • Members
  • 112 posts
  • 0 thanks
  • Local time: 03:12 AM
  • LocationSt. Ingbert, Saarland, Germany

Hey, first off, thanks a lot for this batch file, worked great on FMA Brotherhood FLAC audio to AC3. :)

But then i tried  converting OZCs Cowboy Bebop 720p AAC Audio to to AC3 and i got this error message for every file (or even every stream, to be precise):

 
Decoding with DirectShow ( Nero Audio Decoder 2 )
Getting "Nero Audio Decoder 2" instance failed.
Aborted at file position blablabla

 

 

I then read the instructions again (duh... :sweat: ) and noticed NeroAAC wasn't in the same folder as eac3to, so I downloaded the newest version and then put it in the same folder as eac3to.exe and tried again. Same thing. What am I doing wrong here? :(


Posted Image

#7
Cman21

Cman21

    /)*(\ ^_^

  • Administrators
  • 2,440 posts
  • 257 thanks
  • Local time: 09:12 PM
first off why would you want to convert AAC to AC3? and second this may be because of the Hev2 codec.

#8
WaveZero

WaveZero

    LOLing

  • VIP
  • 705 posts
  • 0 thanks
  • Local time: 09:12 AM
  • LocationAustralia

Well to be honest, the batch file is all great and all. But PopCorn MKV AudioConverter is what I use, sure it's only mkv but it works pretty decent for me.

 

http://www.videohelp...-AudioConverter


Posted Image


#9
skycamefalling84

skycamefalling84

    Mushi

  • Members
  • 112 posts
  • 0 thanks
  • Local time: 03:12 AM
  • LocationSt. Ingbert, Saarland, Germany

first off why would you want to convert AAC to AC3? and second this may be because of the Hev2 codec.

My A/V-Receiver is about ...well, I don't know, around 4 years old and it only cost 150€ then, so it's not top of the line. It DOES play AAC or FLAC, but only outputs Stereo when doing so. And apart from that it does a really good job, so...

 

Well to be honest, the batch file is all great and all. But PopCorn MKV AudioConverter is what I use, sure it's only mkv but it works pretty decent for me.

 

http://www.videohelp...-AudioConverter

Thanks, I'll try it out :)
I was searching the web for a nice converter, but everyone I got my hands on presented some kind of problem...

 

Edit:
Tried it out, works like a breeze :) Thanks a bunch!


Edited by skycamefalling84, 17 September 2013 - 10:36 AM.

Posted Image

#10
FoxesDen

FoxesDen

    Red Ribbon Army

  • VIP
  • 563 posts
  • 23 thanks
  • Local time: 09:12 PM
  • LocationGreat White North
I'm guessing your audio receiver uses a fiber optic cable, which is why only AC3 can be bitstreamed in 5.1.

According to this site that error message means "the Nero decoder isn't installed in your pc". I seem to recall there are issues when using newer versions of the Nero AAC Encoder. Try downloading and using the one I uploaded. Also, make sure the file is called neroAacEnc.exe that you're putting in the same folder as eac3to.exe. I don't have Nero installed on my computer at all, and only use that one file.

EDIT: Oh wait, you're converting FROM AAC. That's a different matter. I'm not sure what Eac3to expects for this. It may use neroAacDec.exe (vs neroAacEnc.exe), I don't know. It may also use Faad.exe. People don't usually convert from AAC, so I can't say anything for sure without further research.

EDIT2: neroAacEnc.exe nor Faad.exe works. Best I can tell from what I've read is that you need NERO 7.8.5.0 or newer installed to convert "from" AAC using Eac3to. Otherwise that "PopCorn MKV AudioConverter" that Ang3lofDarkness referred you to seems ideal for your purposes. It's purpose is specifically for what you want; to convert all audio to AC3, be it for bitstreaming or for devices that only support AC3.
ztor6.jpg

#11
skycamefalling84

skycamefalling84

    Mushi

  • Members
  • 112 posts
  • 0 thanks
  • Local time: 03:12 AM
  • LocationSt. Ingbert, Saarland, Germany

I'm guessing your audio receiver uses a fiber optic cable, which is why only AC3 can be bitstreamed in 5.1.
 

Yeah, I'm using fiber optic. DTS works as well, though. I thought fiber optic was the best option?!


Posted Image

#12
Cman21

Cman21

    /)*(\ ^_^

  • Administrators
  • 2,440 posts
  • 257 thanks
  • Local time: 09:12 PM
oh i completely forgot about that... i know if you have a good sound card in your PC it will automatically convert to DTS audio so you dont have to worry about that issue too much.

#13
FoxesDen

FoxesDen

    Red Ribbon Army

  • VIP
  • 563 posts
  • 23 thanks
  • Local time: 09:12 PM
  • LocationGreat White North

I thought fiber optic was the best option?!

HDMI is the best option. It is the ONLY option that can bitstream 5.1 losslessly. And just two weeks ago HDMI 2.0 was released which can also bitstream HE-AAC (which fiber optic can't do either). I imagine there are a lot of lossless fanatics out there who are only getting 2.0 audio out the other end and don't even realize it.
ztor6.jpg


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users