Convert .wav to .mp3 using Lame.exe in C#

public void mciConvertWavMP3(string fileName, bool waitFlag)
{
//maxLen is in ms (1000 = 1 second)
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.WorkingDirectory=pworkingDir;
psi.WindowStyle=System.Diagnostics.ProcessWindowStyle.Minimized;
System.Diagnostics.Process p=System.Diagnostics.Process.Start(psi);
if (waitFlag)
{
p.WaitForExit();
// wait for exit of called application
}
}

This code will help us to convert .wav file in to .mp3

...S.VinothkumaR.

5 comments:

Singee said...

Works perfectly, thanks a lot!

Priyank Bolia said...

Looks to me plagiarism, copied from http://www.csharphelp.com/archives/archive264.html, without any modification, extension.
Bad Bad Bad...

vipin said...

Hi,
I want to know that how lame.exe can be used in the provided code.

(by registering it !)

I have no idea so please tell me in detail.

Thanks

Ram said...

Hi vinoth,

I tried the sample above, but tis not working.

i've downloaded lame.exe, and the code runs without exception, but no output.

can you explaing in details. its an urgent work. please reply

Author said...

Thanks for the post

convert mp3 to wav