2017-09-10 8 views
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でこれを正しく実行する方法がわかりません。

答えて

0

私はあなたの議論を試み、StandardOutputプロパティを介して出力を得ました。 コードを下に変更してもう一度お試しください。

StreamReader reader = process.StandardOutput; 
関連する問題