I am running ffmpeg in Java. Using p = Runtime.getRuntime().exec(command);
It is used to stream video through a red5 server.
My problem is that ffmpeg requires "q" to be pressed in order to stop. How can I do that? How can I send the q character to the running process so it will execute p.destroy();
or something similar? At the moment it runs forever until I kill the process in the task manager. I am using Windows7.
To inject the 'q' key into the running process, you can do something like this:
OutputStream ostream = p.getOutputStream(); //Get the output stream of the process, which translates to what would be user input for the commandline
ostream.write("q\n".getBytes()); //write out the character Q, followed by a newline or carriage return so it registers that Q has been 'typed' and 'entered'.
ostream.flush(); //Write out the buffer.
This should successfully 'quit' the running ffmpeg process.