Java Runtime.exec () and pass getch () character

I want to run ffmpeg from java as an external process. In a few minutes I want to stop this. He asks me to press "q" and it works in the console, but when I try to write "q" to my stdin (process.getOutputStream () using java - it does not work.

I just take "c", convert it to byte, using ASCII encoding, write it to the stream, clear and close it. Ffmpeg does not stop.

I briefly looked at its sources and found that it uses the getch () function, which (according to the manual) "reads a character from a connected terminal."

ffmpeg may also stop on signal, but it also does not work in windows.

Does anyone know how to solve my problem?

And yes: I really want to run ffmpeg as an external program. I know about xuggle, but it doesn’t work for me, I need naked ffmpeg and I don’t want to write JNI right now.

Thank!

+2
java ffmpeg
Sep 23 '10 at 1:58
source share
1 answer

See, readch () reads a single character from the terminal keyboard, not the input stream! On * nix, it uses ioctl, on Windows (I believe) some kind of Console API.

It looks like I can not stop ffmpeg from java without JNI :(

0
Sep 23 2018-10-11T00:
source share



All Articles