0
我使用的是FFMPEG Process
收集有关文件的一些信息:C#工艺参数和输出缺
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();
}
这似乎正常工作。现在,我想只是FrameRate
和thanks to other posts,我发现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_entries stream = r_frame_rate
不起作用,只有-show_entries stream=r_frame_rate
无空格。
我不知道如何正确地使用Process
来做这件事。