2012-07-18 36 views
3

我正在使用ffmpeg編譯視頻,並且我想阻止它在執行操作時顯示控制檯。防止子進程在c中顯示shell窗口#

我是這樣開始的ffmpeg:

ProcessStartInfo si = new ProcessStartInfo(); 
si.Arguments = string.Format("-y -loop 1 -t " + DucationToString(frameDuration) + " -r 25 -f image2 -i \"{0}\" \"{1}\"", 
          item.Value, otpt); 
si.FileName = "ffmpeg"; 
si.UseShellExecute = false; 

Process.Start(si).WaitForExit(); 

無論設置我嘗試在ProcessStartInfo,控制檯總是顯示出來。

如何防止在創建子進程時顯示控制檯?

回答

5

你應該嘗試使用

ProcessStartInfo si = new ProcessStartInfo(); 
si.WindowStyle = ProcessWindowStyle.Hidden; 
si.CreateNoWindow = true; 
si.UseShellExecute = false; 

MSDN refs

+0

我認爲還有一個名爲CreateNoWindow的屬性並將其設置爲true – 2012-07-18 10:03:46

1

你有沒有在你的代碼

si.CreateNoWindow = true; 
    si.RedirectStandardOutput = true; 
2

設置ProcessStartInfo.CreateNoWindowtrue加入此。

注意說:

要使用ProcessWindowStyle.HiddenProcessStartInfo.CreateNoWindowProcessStartInfo.UseShellExecute屬性必須是false