In reference to this question, as you can see I managed to run and receive data from the program.
However I didn't manage to submit data to it, for instance, while converting a file, pressing q
immediately stop conversion and stops the program.
I need my application to support stopping the process as well, and I think this should be done by passing this parameter to the ffmpeg app, since I want it to take care of all uncollected resource or whatever dust it would leave behind if I would just go and use process.Kill()
Here is what I've tried:
static int lineCount = 0;
static bool flag;
static void process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine("Error ({1:m:s:fff}: {0})", lineCount++,
DateTime.Now);
if (e.Data != null && string.Equals(e.Data,"Press [q] to stop, [?] for help"))
flag = true;
if (flag)
{
flag = false;
Console.WriteLine("Stopping ({0:m:s:fff})...", DateTime.Now);
process.CancelErrorRead();
process.CancelOutputRead();
process.StandardInput.WriteLine("q");
}
Console.WriteLine(e.Data);
Console.WriteLine();
}
But it doesn't do anything, seems that once the conversion has been requested, I have no control on it any more, I can only receive output from it. Running it as stand alone does allow me interaction of course.
What am I missing here, is it a different trick in submitting the output or the code in previous answer is wrong, or I should have chosen a different approach?
For your attention, RedirectStandardInput
is on.
NOTE: as you can see in the answer of my previous question, ffmpeg interacts differently, I think the one who knows the answer will be (maybe I'm wrong) someone with experience in ffmpeg.