Comverting audio files to mp4 format using C# in Asp.net

Jul 7 2012 3:41 AM
Please anyone can solve my query..
My query....I want to convert audio files in different formats...My code is uploading a song(audio)and convert that audio to mp4 format..uploaded song stored in the folder..and convert function calld that audio from that folder where it stored..
Thank u in advanced...
please Help me...
My code is below...



protected void btnConvertTo_MP4_Click(object sender, EventArgs e)
  //Button to convert audio file
{

MediaManagerPro oMediaManagerPro = new MediaManagerPro();

//Get the rooth path
string strRootPath = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath);

//set the directory path info for ffmpeg file
oMediaManagerPro.FFMPEG_Path = HttpContext.Current.Server.MapPath("~\\ffmpeg\\ffmpeg.exe");



//oMediaManagerPro.SourceFile_Path = strRootPath + "\\contents\\MP3";


//oMediaManagerPro.OutputFile_Path = strRootPath + "\\contents\\MP4";
string filename = @"C:\CLASSPROJEcTS\WebSite5\Uploads\{0}";
//Set source file info
oMediaManagerPro.SourceFile_Path = strRootPath + "\\Uploads";
oMediaManagerPro.SourceFile_Name = Path.GetFileName(filename);


//set output file info
oMediaManagerPro.OutputFile_Path = strRootPath + "\\contents\\MP4";
oMediaManagerPro.OutputFile_Name = "abc.mp4";

//call ConvertTo_MP3 method
MediaInfo oMediaInfo = oMediaManagerPro.ConvertTo_MP4();

// retrieve video informatioin
if (oMediaInfo.Error_Code > 0)
{
HttpContext.Current.Response.Write(":: Video processing failed ::<br/>Error code: " + oMediaInfo.Error_Code + "<br />Error Message: " + oMediaInfo.Error_Message);
return;
}

protected void UploadButton_Click(object sender, EventArgs e)
//button to Upload audio and save it in folder.
{
if (FileUpload1.HasFile)
{
string fileExt =
System.IO.Path.GetExtension(FileUpload1.FileName);

if (fileExt == ".mp3")
{
try
{
FileUpload1.SaveAs(Server.MapPath("~/Uploads/" +
FileUpload1.FileName));
Label1.Text = "File name: " +
FileUpload1.PostedFile.FileName + "<br>" +
FileUpload1.PostedFile.ContentLength + " kb<br>" +
"Content type: " +
FileUpload1.PostedFile.ContentType;
}
catch (Exception ex)
{
Response.Redirect("Default.aspx");
Label1.Text = "ERROR: " + ex.Message.ToString();
}
}
else
{
Label1.Text = "Only .mp3 files allowed!";
}
}
else
{
Label1.Text = "You have not specified a file.";
}
}
}