如图,正常通过打开cmd.exe控制台输入使用这个命令去剪辑视频是没有问题的,但是通过C#代码去启动Process类执行cmd命令执行这个ffmpeg命令就会卡在红色框那句代码那里不返回出来
public static string ExecFFmpegCommand(string cmd)
{
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
process.Start();
process.StandardInput.WriteLine(cmd + "&exit");
process.StandardInput.AutoFlush = true;
string output = process.StandardOutput.ReadToEnd();
Trace.TraceInformation(output);
string error = process.StandardError.ReadToEnd();
if (!string.IsNullOrEmpty(error))
{
Trace.TraceError(error);
}
process.WaitForExit();
process.Close();
return output + error;
}
直接启动ffmpeg剪切视频就好了,不需要cmd,不过获取不到控制台输出