Recently in the development of public numbers encountered a problem, that is, received the voice message format AMR, on the Web page usually can not play directly, need to first to MP3, so found a way, Using Ffmpeg.exe, online can search the use of ffmpeg.exe, including a variety of voice, video conversion, The following is an example of AMR to MP3 in. NET for your reference, did not tidy up, directly copy the code in the project, call the ConvertAmrToMp3 method, to achieve more conversions please modify the command to
<summary>///convert AMR audio to MP3///</summary>/<param name= "fileName" > File path before conversion < ;/param>//<param name= "Targetfilname" > converted file path </param> public static void ConvertAmrToMp3 ( String fileName, String targetfilname) {startprocess (AppDomain.CurrentDomain.BaseDirectory + @ "\ffmpeg. EXE ", String. Format ("-i \" {0}\ "\" {1}\ "", FileName, Targetfilname)); Compress MP3//startprocess (AppDomain.CurrentDomain.BaseDirectory + @ "\ffmpeg.exe", String. Format (@ "-i {0}-ac 1-ar 8000-ab 7950-y {1}", FileName, Targetfilname)); }//performs a conversion to private static void StartProcess (String fileName, String args) {process process = Process.Start (new ProcessStartInfo {filename = filename, Arguments = args, UseShellExecute = False, Redirectstandardinput = false, Redirectstandardoutput = False CreateNoWindow = true}); Process. WaitForExit (); Process. Close (); }
. NET voice, video and other format conversions