Objective
The previous article has shared with you the asp.net use of the seven-cow conversion method will be. Amr mp3 method, at that time also said that there is another way to use the FFmpeg conversion method, the following article will give you a detailed description of this method. This method is much simpler than the first.
FFmpeg's name comes from the MPEG video coding standard, the front "FF" represents "Fast Forward", and FFmpeg is a set of open source computer programs that can be used to record, convert, and transform digital audio and video into streams. It is easy to convert multiple video formats to each other.
FFmpeg conversion method
First, you have to download a "Ffmpeg.exe" plugin and put it in your project, as shown in the following figure:
The file is called in the program to help convert the audio format!
Code on:
The code is as follows |
Copy Code |
Publicpartialclasscowala_201512Chritmas_amrtest:System.Web.UI.Page
Protectedvoidpage_load (Objectsender, EventArgs e)
Changedplay.visible =false;
Protectedvoidffmpeg_click (Objectsender, EventArgs e)
Stringkey = Amrfileup.filename;
Stringsavepath = Server.MapPath ("~/upload/amr/") + key;
Amrfileup.saveas (Savepath);
Stringmp3savepth = Server.MapPath ("~/upload/mp3/") + key. Split ('. ') [0]. ToString () + ". mp3";
if (!string. IsNullOrEmpty (CONVERTTOMP3 (Savepath, mp3savepth))
Changedplay.visible =true;
CHANGEDPLAY.ATTRIBUTES.ADD ("src", "upload/mp3/" + key. Split ('. ') [0]. ToString () + ". mp3");
Response.Write ("<script>alert") (' Convert success! ');</script> ");
PUBLICSTRINGCONVERTTOMP3 (Stringpathbefore,stringpathlater)
STRINGC = Server.MapPath ("/ffmpeg/") +@ "ffmpeg.exe-i" + Pathbefore + "" + pathlater;
Privatestringruncmd (STRINGC)
ProcessStartInfo Info =newprocessstartinfo ("cmd.exe");
Info. Redirectstandardoutput =false;
Info. UseShellExecute =false;
Process p = Process.Start (info);
P.startinfo.useshellexecute =false;
P.startinfo.redirectstandardinput =true;
P.startinfo.redirectstandardoutput =true;
P.startinfo.redirectstandarderror =true;
P.standardinput.writeline (c);
P.standardinput.autoflush =true;
P.standardinput.writeline ("Exit");
Stringoutstr = P.standardoutput.readtoend ();
Return "error" + ex. message;
|
Next to the effect of the picture: