这是我无法理解为什么它显示进程的控制台窗口的代码。
class Ffmpeg
{
NamedPipeServerStream p;
String pipename = "mytestpipe";
byte[] b;
System.Diagnostics.Process process;
string ffmpegFileName;
string workingDirectory;
public Ffmpeg()
{
workingDirectory = Path.GetDirectoryName(Application.LocalUserAppDataPath) + @"\workingDirectory";
ffmpegFileName = @"\ffmpeg.exe";
if (!Directory.Exists(workingDirectory))
{
Directory.CreateDirectory(workingDirectory);
}
ffmpegFileName = workingDirectory + ffmpegFileName;
}
public void Start(string pathFileName, int BitmapRate)
{
string outPath = pathFileName;
p = new NamedPipeServerStream(pipename, PipeDirection.Out, 1, PipeTransmissionMode.Byte);
b = new byte[1920 * 1080 * 3]; // some buffer for the r g and b of pixels of an image of size 720p
ProcessStartInfo psi = new ProcessStartInfo();
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
psi.CreateNoWindow = false;
psi.FileName = ffmpegFileName;
psi.WorkingDirectory = workingDirectory;
psi.Arguments = @"-f rawvideo -pix_fmt bgr0 -video_size 1920x1080 -i \\.\pipe\mytestpipe -map 0 -c:v libx264 -r " + BitmapRate + " " + outPath;
//psi.RedirectStandardOutput = true;
process = Process.Start(psi);
process.EnableRaisingEvents = false;
p.WaitForConnection();
}
我做了 psi.WindowStyle = ProcessWindowStyle.Hidden; 但是当我运行该过程时,我仍然看到了窗口。这是为什么 ?