1

我正在开发一个 Windows 窗体程序,它通过类调用ffmpegProcess

当我在 Visual Studio 2013 中使用 Debug 运行它时它工作正常。但是当我安装程序并调用调用ffmpeg Process的操作时,它不起作用。cmd屏幕出现消失,没有任何反应。

我试图知道获取带有 ffmpeg 输出的日志文件会发生什么以防ffmpeg库中出现问题。但是执行完后日志是空的,说明ffmpeg命令还没有执行。

有人能帮助我吗?

代码是这样的:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/c " + ffmpegPath + " " + commandArguments;
using (Process processTemp = new Process())
{
    processTemp.StartInfo = startInfo;
    processTemp.EnableRaisingEvents = true;
    processTemp.Start();
    processTemp.WaitForExit();
}

我正在调用cmd.exe(不是直接调用ffmpeg.exe),因为在参数中有时可以有一个管道(这就是命令以“ /c”开头的原因)。

4

2 回答 2

0

您确定这不是尝试执行 cmd.exe 时的权限问题(例如,您需要管理员权限)

尝试添加

startInfo.Verb = "runas";

保罗

于 2019-02-05T15:50:36.383 回答
0

Hmm its not a path issue with spaces in file/directory names is it? For ffmpegPath or one of your command parameters (if a file path). Surround all file paths with ' like below.

Try surrounding any file paths with '

 startInfo.Arguments = "/c '" + ffmpegPath + "' " + commandArguments;

Also you could try adding /K to the cmd command call to stop if from closing the command prompt when it finishes. It might tell you the error before it closes the window but you wont see it if it closes so quickly

Good luck :) Paul

于 2019-02-06T16:50:16.280 回答