2017-09-10 2 views
0

Ich bin ein FFMPEG Process mit einigen Informationen über eine Datei zu sammeln:C# Prozess Argumente und Fehlende Output

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(); 
} 

Das scheint funktioniert gut. Jetzt will ich nur bekommen die FrameRate und thanks to other posts, habe ich festgestellt, dass ffprobe verwendet werden kann, genau das zu tun:

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(); 
} 

Dies scheint nicht überhaupt zu arbeiten. Der Prozess startet, gibt aber nicht das zurück, was ich erwartet habe.

Wenn ich den Befehl manuell ausführen, kann ich folgende in 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 

Hinweis: -show_entries stream = r_frame_rate nicht funktioniert, nur -show_entries stream=r_frame_rate ohne Leerzeichen.


Ich bin nicht sicher, wie man richtig über gehen, diese Process mit einem zu tun.

Antwort

0

Ich versuchte Ihr Argument und bekam die Ausgabe durch StandardOutput Eigenschaft. Bitte ändern Sie Ihren Code einfach und versuchen Sie es erneut.

StreamReader reader = process.StandardOutput; 
Verwandte Themen