2010-11-23 34 views
3

將MPG文件轉換爲AVI文件時出現問題。當我轉換一個文件時,例如520KB MPG文件,我的程序就會生成一個大約112MB的AVI文件,並且該視頻無法正常工作。什麼會造成這種情況?使用C#中的ffmpeg.exe將MPG轉換爲AVI

 string path = "C:\\convert\\input.mpg" 
    string outputpath = "C:\\convert\\"+output+".avi"; 

    string fileargs = "-i" + " " + path + " " + outputpath; 


     System.Diagnostics.Process p = new System.Diagnostics.Process(); 
     p.StartInfo.FileName = "C:\\convert\\ffmpeg.exe"; 
     p.StartInfo.Arguments = fileargs; 
     p.StartInfo.UseShellExecute = false; 
     p.StartInfo.CreateNoWindow = true; 
     p.StartInfo.RedirectStandardOutput = true; 
     p.Start(); 


     p.WaitForExit(); 
+0

嘗試讀取命令行舉例開關,你就什麼事情弄清楚。順便說一句,你的問題與C#無關,你的代碼是確定的。 – 2010-11-23 15:10:12

回答

0

的ffmpeg有許多選項。這可能需要一些實驗來獲得正確的設置。

1

我已經使用QuickTime重新包裝。不知道它會在AVI上工作得很好,但你可以去一趟。

fileargs = String.Format("-i {0} -vcodec copy -acodec copy {1}", path, outputpath); 

,或者,如果不工作,你可以嘗試:

fileargs = String.Format("-i {0} -vcodec copy -acodec pcm_s16le {1}", path, outputpath);