Stopping Process
-
I am using FFMPEG for streaming operations. (https://www.transferbigfiles.com/a3209f95-ffcc-4c82-b722-041a24c26ec1?rid=KsWHbP3Lo/rxGH4YHVVVtA%3D%3D) I started it using the following program
Process myProcess = new Process(); myProcess.StartInfo.FileName = @"ffmpeg.exe"; myProcess.StartInfo.UseShellExecute = false; myProcess.StartInfo.RedirectStandardInput = true; myProcess.StartInfo.Arguments = "-i input.avi -vcodec copy -acodec copy output.avi"; myProcess.Start(); StreamWriter myStreamWriter = myProcess.StandardInput; myStreamWriter.Write("113"); //using ascii of q myStreamWriter.Flush(); myStreamWriter.Write('q'); myStreamWriter.Flush(); myStreamWriter.Close(); myProcess.WaitForExit(); myProcess.Close();
My intention is to close the program when I send "q" from the program (I meant a graceful exit without making any error). But I can't close it by sending 'q' character or its corresponding ascii. When I run the program from the command line and I press q in the keyboard, program immediately gets closed. Can you pls. help me? Thank you regards anvesh
-
I am using FFMPEG for streaming operations. (https://www.transferbigfiles.com/a3209f95-ffcc-4c82-b722-041a24c26ec1?rid=KsWHbP3Lo/rxGH4YHVVVtA%3D%3D) I started it using the following program
Process myProcess = new Process(); myProcess.StartInfo.FileName = @"ffmpeg.exe"; myProcess.StartInfo.UseShellExecute = false; myProcess.StartInfo.RedirectStandardInput = true; myProcess.StartInfo.Arguments = "-i input.avi -vcodec copy -acodec copy output.avi"; myProcess.Start(); StreamWriter myStreamWriter = myProcess.StandardInput; myStreamWriter.Write("113"); //using ascii of q myStreamWriter.Flush(); myStreamWriter.Write('q'); myStreamWriter.Flush(); myStreamWriter.Close(); myProcess.WaitForExit(); myProcess.Close();
My intention is to close the program when I send "q" from the program (I meant a graceful exit without making any error). But I can't close it by sending 'q' character or its corresponding ascii. When I run the program from the command line and I press q in the keyboard, program immediately gets closed. Can you pls. help me? Thank you regards anvesh
anveshvm wrote:
Can you pls. help me?
I believe so; see my ProcessCommunicator[^] article.
-
I am using FFMPEG for streaming operations. (https://www.transferbigfiles.com/a3209f95-ffcc-4c82-b722-041a24c26ec1?rid=KsWHbP3Lo/rxGH4YHVVVtA%3D%3D) I started it using the following program
Process myProcess = new Process(); myProcess.StartInfo.FileName = @"ffmpeg.exe"; myProcess.StartInfo.UseShellExecute = false; myProcess.StartInfo.RedirectStandardInput = true; myProcess.StartInfo.Arguments = "-i input.avi -vcodec copy -acodec copy output.avi"; myProcess.Start(); StreamWriter myStreamWriter = myProcess.StandardInput; myStreamWriter.Write("113"); //using ascii of q myStreamWriter.Flush(); myStreamWriter.Write('q'); myStreamWriter.Flush(); myStreamWriter.Close(); myProcess.WaitForExit(); myProcess.Close();
My intention is to close the program when I send "q" from the program (I meant a graceful exit without making any error). But I can't close it by sending 'q' character or its corresponding ascii. When I run the program from the command line and I press q in the keyboard, program immediately gets closed. Can you pls. help me? Thank you regards anvesh
Come to think of it, you may only need to add a CARRIAGE-RETURN character.
-
anveshvm wrote:
Can you pls. help me?
I believe so; see my ProcessCommunicator[^] article.
Thanx for the reply, Its actually a nice article. But I couldn't solve my issue using it. A carriage return is not necessary for this application to close. Pressing a 'q' itself (from keyboard) will give give graceful end to the program. I need not press an additional enter key. And as an additional step of precaution, I made my own console program which requries a 'q' followed by carriage return to close the application, and it worked fine when I use WriteLine from .NET What might be the issue? Its only for ffmpeg that I can't send input stream to. I am anxious to know what might be the issue?
-
Thanx for the reply, Its actually a nice article. But I couldn't solve my issue using it. A carriage return is not necessary for this application to close. Pressing a 'q' itself (from keyboard) will give give graceful end to the program. I need not press an additional enter key. And as an additional step of precaution, I made my own console program which requries a 'q' followed by carriage return to close the application, and it worked fine when I use WriteLine from .NET What might be the issue? Its only for ffmpeg that I can't send input stream to. I am anxious to know what might be the issue?
I don't know, I'm stumped. But maybe the program reads something internal instead of the input stream. What is ffmpeg? Maybe I can try it.
-
Thanx for the reply, Its actually a nice article. But I couldn't solve my issue using it. A carriage return is not necessary for this application to close. Pressing a 'q' itself (from keyboard) will give give graceful end to the program. I need not press an additional enter key. And as an additional step of precaution, I made my own console program which requries a 'q' followed by carriage return to close the application, and it worked fine when I use WriteLine from .NET What might be the issue? Its only for ffmpeg that I can't send input stream to. I am anxious to know what might be the issue?
anveshvm wrote:
WriteLine
Oh, yeah, that may actually send a LINEFEED and a CARRIAGE-RETURN. If so, you would have to set the NewLine property.
-
I don't know, I'm stumped. But maybe the program reads something internal instead of the input stream. What is ffmpeg? Maybe I can try it.
ffmpeg produces libraries and programs for handling multimedia. We can convert media files into different formats using ffmpeg. It can also record live streams from a camera in different formats. I am attaching the ffmpeg.exe here. https://www.transferbigfiles.com/a3209f95-ffcc-4c82-b722-041a24c26ec1?rid=KsWHbP3Lo/rxGH4YHVVVtA%3d%3d[^] Here in my code i just copy the audio and video codecs of a file (input.avi) into another file(output.avi). Different parameters can be added in this command, but I just consider the basic operation here.
Process myProcess = new Process(); myProcess.StartInfo.FileName = @"ffmpeg.exe"; myProcess.StartInfo.UseShellExecute = false; myProcess.StartInfo.RedirectStandardInput = true; myProcess.StartInfo.Arguments = "-i input.avi -vcodec flv -acodec copy output.flv"; myProcess.Start(); StreamWriter myStreamWriter = myProcess.StandardInput; myStreamWriter.Write("113"); //using ascii of q myStreamWriter.Flush(); myStreamWriter.Write('q'); myStreamWriter.Flush(); myStreamWriter.Close(); myProcess.WaitForExit(); myProcess.Close()
;
If i run the pgm ( ffmpeg.exe should be placed in same foldr) it starts the conversion from avi to flv. When I press [q] the pgm gets closed gracefully. But I I am not being able to close it by sending 'q' character or its corresponding ascii. :confused: