/// <param name="filePath">ffmpeg.exe的文件路径</param> /// <param name="Parameters">ffmpeg命令行</param> private static void RunProcess(string filePath, string Parameters) { ProcessStartInfo procStartInfo = new ProcessStartInfo(filePath, Parameters); procStartInfo.RedirectStandardOutput = true; procStartInfo.UseShellExecute = false; procStartInfo.CreateNoWindow = true; procStartInfo.WorkingDirectory = Environment.CurrentDirectory; //开启线程 Process process = new Process() { StartInfo = procStartInfo, }; process.Start(); process.WaitForExit(); if (process.ExitCode != 0) { throw new LibreOfficeFailedException(process.ExitCode); } }
注意,ffmpege要放在程序的bin目录下,不然线程会一直执行
参考资料:https://blog.csdn.net/zhongjie112/article/details/50448327
https://www.jianshu.com/p/2f9e31dd291f