var args = argsBuild.ToString(); var ffmpegProcess = new Process(); ffmpegProcess.StartInfo.FileName = Cmd; ffmpegProcess.StartInfo.Arguments = args; // 禁用操作系统外壳程序,异步时需做这些配置 ffmpegProcess.StartInfo.UseShellExecute = false; ffmpegProcess.StartInfo.CreateNoWindow = true; ffmpegProcess.StartInfo.RedirectStandardOutput = true; ffmpegProcess.StartInfo.RedirectStandardError = true; ffmpegProcess.Start(); // 异步获取命令行内容 ffmpegProcess.BeginOutputReadLine(); ffmpegProcess.BeginErrorReadLine(); // 为异步获取订阅事件 ffmpegProcess.ErrorDataReceived += FfmpegProcess_ErrorDataReceived; //为异步获取订阅事件 ffmpegProcess.OutputDataReceived += FfmpegProcess_OutputDataReceived; void FfmpegProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e) { //每次输出都会触发 } void FfmpegProcess_OutputDataReceived(object sender, DataReceivedEventArgs e) { //输出完毕时触发 }