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
來做這件事。