11

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

Nick
  • 7,475
  • 18
  • 77
  • 128
  • 2
    Regarding commercial usage: http://lame.sourceforge.net/license.txt There may also be patent restrictions in your country. – Mark Byers Dec 27 '09 at 23:58
  • Can anyone explain how to use this? Where can I find the correct Lame.dll for me and how do I tell which to use? How and where can this be added into an existing asp.net web application? What files need to be placed where? How do I properly refference the files? How do I properly populate the parameters? What is the waitFLag Parameter? .. How do I get this going? –  Jul 03 '11 at 21:11

2 Answers2

14

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
  • 2,221
  • 1
  • 16
  • 14
2

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
  • 1,023,142
  • 271
  • 3,287
  • 2,928