Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting wav to mp3 - ASP.NET

Tags:

c#

.net

asp.net

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

like image 990
Nick Avatar asked Dec 27 '09 23:12

Nick


2 Answers

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();
        }
 }
like image 156
afftee Avatar answered Nov 20 '22 09:11

afftee


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.

like image 36
Darin Dimitrov Avatar answered Nov 20 '22 11:11

Darin Dimitrov