2010-11-23 33 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);