The best and the shortest solution was found in the article
' Video Transcoding "YouTube-Style" with ffmpeg ' posted by Jonathan Lathigee.
Video Transcoding "YouTube-Style" with ffmpeg
He writes:
"Another problem came in the capturing of output from FFMPEG to get all of the file's metadata. I created a new process and streamReader, and captured the StandardOutput from the process. Nothing. Turns out that there is no specific command in FFMPEG to read metadata from a video file, instead this info comes out as a StandardError stream when FFMPEG is called with no output file specified. Once I switched from capturing the StandardOutput to StandardError, I had no problems."
And that was key factor for me. As I tried to catch StandardOutput of ffmpeg instead of catching StandardError. So I got all necessary lines into my TextBox. Finally I used asynchronous reading that was more suitable for my purpose. Here is the code.
try
{
Process p = this.process1;
String input = " -i " + this.listBox2.Text;
String size = " -s " + this.comboBox1.Text;
String codec = " -vcodec " + this.comboBox2.Text;
String encoder = " -vtag " + this.comboBox3.Text;
String quality = " -qscale " + this.comboBox4.Text;
String videobr = " -b:v " + this.comboBox4.Text + "k";
String audiobr = " -ab " + this.comboBox5.Text + "k";
String output = " -y " + this.textBox2.Text;
String report = " 2> \"" + this.textBox2.Text + ".log\"";
String s = input + size + codec + encoder + videobr + audiobr + output;
String sa = " -h ";
p.StartInfo.Arguments = s;
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
MessageBox.Show("Waiting for the process to exit....");
if (p.HasExited) { p.CancelErrorRead(); p.CancelOutputRead(); p.Close(); MessageBox.Show("Closed"); }
}
catch (Exception ex)
{
MessageBox.Show("1.\n"+ex.Message);
}
Following ErrorDataReceived handler.
private void process1_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
this.textBox1.Text += e.Data;
this.textBox1.Update();
}
You can find some extra lines: MessageBoxes etc. they are just for debugging.
So Great Thanks to Jonathan Lathigee and 5 stars for him.
I'm glad if my experience is usefull for you.
Best wishes.