I'm using ffmpeg to compile videos, and I'd like to prevent it from displaying a console when performing actions.
Here's how I start 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();
No matter the settings I try in ProcessStartInfo
, the console always shows up.
How do I prevent the console from being shown when creating child process?
Steve
You should try to use
ProcessStartInfo si = new ProcessStartInfo();
si.WindowStyle = ProcessWindowStyle.Hidden;
si.CreateNoWindow = true;
si.UseShellExecute = false;
Set ProcessStartInfo.CreateNoWindow
to true
.
Note that:
To use ProcessWindowStyle.Hidden
or ProcessStartInfo.CreateNoWindow
the ProcessStartInfo.UseShellExecute
property must be false
.
Have you added this in your code
si.CreateNoWindow = true;
si.RedirectStandardOutput = true;
来源:https://stackoverflow.com/questions/11538848/prevent-child-process-from-showing-a-shell-window-in-c-sharp