ffmpeg音频转换

   /// <summary>
        /// 音频amr格式转换为mp3格式
        /// </summary>
        private void AmrConvertToMP3()
        {
            string amr = "/amr/bubugao.amr";
            string mp3 = "mp3/bubugao.mp3";
            string ffmpeg = "/ffmpeg/ffmpeg.exe";
            amr = Server.MapPath(amr);
            mp3 = Server.MapPath(mp3);
            ffmpeg = Server.MapPath(ffmpeg);

            string args = ffmpeg + " -y -i " + amr + " -ar 8000 -ab 12.2k -ac 1 " + mp3;

            try
            {
                System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo.FileName = "cmd.exe";
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow = true;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardInput = true;
                process.Start();

                process.StandardInput.WriteLine(args);
                process.StandardInput.AutoFlush = true;
                process.StandardInput.WriteLine("exit");

                //StreamReader reader = process.StandardOutput;//截取输出流           

                process.WaitForExit();
            }
            catch
            { }
        }

 

posted @ 2015-04-19 11:56  清幽紫竹  Views(169)  Comments(0)    收藏  举报