Convert MP3 to AAC,FLAC to AAC (.NET/C#) FREE :)

Posted by PearlFactory on Geeks with Blogs See other posts from Geeks with Blogs or by PearlFactory
Published on Wed, 23 Nov 2011 22:19:46 GMT Indexed on 2011/11/24 1:53 UTC
Read the original article Hit count: 381

Filed under:
So I was tasked with looking at converting 10 million tracks from mp3 320k to AAC and also
Converting from mp3 320k to mp3 128k

After a bit of hunting around the tool you need to use is

FFMPEG Download x64 Windows

Also for the best results get the Nero AACEncoder Download

Now the command line

STEP 1
(From Flac)
ffmpeg -i input.flac -f wav - | neroAacEnc -ignorelength -q 0.5 -if - -of output.m4a

or
(From mp3)
ffmpeg -i input.mp3 -f wav - | neroAacEnc -ignorelength -q 0.5 -if - -of output.m4a






Now the output.m4a is a intermediate state that we now put a ACC wrapper on via FFMpeg

STEP 2

ffmpeg -i output.m4a -vn -acodec copy final.aac



Done :)

There are a couple of options with the FFMPEG library as in we can look at importing the librarys and manipulation the API for the direct result FFMPEG has this support. You can get the relevant librarys from Here

They even have the source if you are that keen :-)

In this case I am going to wrap the command lines into c# external process threads.
( For the app that i am building to convert the 10 million tracks there is a complex multithreaded app to support this novel code )

//Arrange Metadata about Call
Process myProcess = new Process();
ProcessStartInfo p = new ProcessStartInfo();
string sArgs = string.format(" -i {0} -f wav - | neroAacEnc -ignorelength -q 0.5 -if - -of {1}",inputfile,outputfil) ; p.FileName = "ffmpeg.exe" ; p.CreateNoWindow = true; p.RedirectStandardOutput = true; //p.WindowStyle = ProcessWindowStyle.Normal p.UseShellExecute = false;
//Execute
 
p.Arguments = sArgs;
myProcess.StartInfo = p;
myProcess.Start();
myProcess.WaitForExit();
//Write details about call
 myProcess.StandardOutput.ReadToEnd();
Now in this case we would execute a 2nd call using the same code but with different sArgs to put the AAC wrapper on the m4a file.

Thats it. So if you need to do some conversions of any kind for you ASP.net sites/apps this is a great start and super fast.. With conversion times of around 2-3 seconds all of this can be done on the fly
:-)

Justin Oehlmann

ref : StackOverflow.com

© Geeks with Blogs or respective owner