ASP.NET 以 FFmpeg 轉換 wmv 格式既 Video 檔 為 flv 格式既 Video 檔

 
ASP.NET 以 FFmpeg 轉換 wmv 格式既 Video 檔 為 flv 格式既 Video 檔
 

   WebForm6.aspx.cs
 
   using System;
   using System.Diagnostics;
 
   namespace WebApplication12
   {
      public partial class WebForm6 : System.Web.UI.Page
      {
         protected void Page_Load(object sender, EventArgs e)
         {
            string VodName = Server.MapPath("video.wmv");
            string NVodname = Server.MapPath("video.flv");
            string strCmd1 = VodName + " -ab 56 -ar 22050 -b 800 -r 29.97 -s 420x340 " + NVodname;
 
            FFMpeg_Process(strCmd1);
         }
 
         public void FFMpeg_Process(string strCmd)
         {
 
            Process p = new Process();
 
            p.StartInfo.FileName = Server.MapPath("ffmpeg.exe");
            p.StartInfo.Arguments = " -i " + strCmd;
            p.StartInfo.UseShellExecute = false;
 
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
 
            p.StartInfo.RedirectStandardError = true;
 
            p.StartInfo.CreateNoWindow = false;
 
            p.Start();
 
            p.BeginErrorReadLine();
 
            p.WaitForExit();
            p.Close();
            p.Dispose();
 
         }
      }
   }
 

註: 需要將 ffmpeg.exe 抄入 WebForm 內, 如覺得有 Security 需要關注 可用 asp.net impersonate 方式去處理