c#进程参数和缺少输出

c#进程参数和缺少输出,c#,process,ffmpeg,ffprobe,C#,Process,Ffmpeg,Ffprobe,我正在使用FFMPEG进程收集文件中的一些信息: private void GatherFrames() { Process process = new Process(); process.StartInfo.FileName = "ffmpeg"; process.StartInfo.Arguments = "-i \"" + filePath + "\""; process.StartInfo.RedirectStandardError = true;

我正在使用
FFMPEG进程
收集文件中的一些信息:

private void GatherFrames()
{
    Process process = new Process();
    process.StartInfo.FileName = "ffmpeg";
    process.StartInfo.Arguments = "-i \"" + filePath + "\"";
    process.StartInfo.RedirectStandardError = true;
    process.StartInfo.UseShellExecute = false;

    if (!process.Start())
    {
        Console.WriteLine("Error starting");
        return;
    }
    StreamReader reader = process.StandardError;
    string line;
    while ((line = reader.ReadLine()) != null)
    {
        outputRichTextBox.AppendText(line + "\n");
    }
    process.Close();
}
这似乎效果不错。现在我只想得到
帧率
,我发现
ffprobe
可以用来实现这一点:

public void GetFrameRate()
{
    Process process = new Process();
    process.StartInfo.FileName = "ffprobe";
    process.StartInfo.Arguments = "-v 0 -of compact=p=0 -select_streams 0 -show_entries stream = r_frame_rate \"" + filePath + "\"";
    Console.WriteLine(process.StartInfo.Arguments);
    process.StartInfo.RedirectStandardError = true;
    process.StartInfo.RedirectStandardOutput = true;
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.CreateNoWindow = false;
    Console.WriteLine(process.StartInfo);

    if (!process.Start())
    {
        Console.WriteLine("Error starting");
        return;
    }

    StreamReader reader = process.StandardError;
    string line;
    while ((line = reader.ReadLine()) != null)
    {
        Console.WriteLine(line);
    }
    process.Close();
}
这似乎根本不起作用。该过程开始,但不返回我期望返回的内容

如果手动运行该命令,我将在
cmd.exe
中执行以下操作:

> e:
> cd "FILE_PATH"
> ffprobe -v 0 -of compact=p=0 -select_streams 0 -show_entries stream=r_frame_rate "FILE_NAME.mp4"
r_frame_rate=60/1
注意:
-show\u entries stream=r\u frame\u rate
不起作用,只有
-show\u entries stream=r\u frame\u rate
没有空格



我不知道如何正确地使用
进程执行此操作

我尝试了您的论点,并通过
标准输出
属性获得了输出。 请将您的代码更改为下面的代码,然后重试

StreamReader reader = process.StandardOutput;