tags:

views:

316

answers:

2

Is there a way to convert WAV files to MP3 in ASP.NET? I have heard of LAME but haven't found any examples for a web application. Also, I wasn't sure if it can be commercially used.

Thanks

+1  A: 

try this code:

public void mciConvertWavMP3(string fileName, bool waitFlag) {
        string outfile= "-b 32 --resample 22.05 -m m \""+pworkingDir+fileName + "\" \"" + pworkingDir+fileName.Replace(".wav",".mp3")+"\"";
        System.Diagnostics.ProcessStartInfo psi=new System.Diagnostics.ProcessStartInfo();
        psi.FileName="\""+pworkingDir+"lame.exe"+"\"";
        psi.Arguments=outfile;
        psi.WindowStyle=System.Diagnostics.ProcessWindowStyle.Minimized;
        System.Diagnostics.Process p=System.Diagnostics.Process.Start(psi);
        if (waitFlag)
        {
        p.WaitForExit();
        }
 }
afftee
I can do this from within a web app?
Yes, it will run on your server, so your server needs to have Lame installed.
keyboardP
it's .NET, so just add this function to your library and call it.
afftee
What is the waitFlag param?
DotnetDude
works fine. quickest solution. lame exe taken from here http://www.rarewares.org/mp3-lame-bundle.phpthanks afftee, you saved me couple of hours!! :)
Konstantin Salavatov
A: 

There's an article on CodeProject showing how to compress a wave file in C# using the Lame codec. It is a managed wrapper around the codec.

Darin Dimitrov