I started the process (via java.lang.Runtime # exec, in Java 6, Linux), for which I only need stdout. Unfortunately, the program I am running (ffmpeg) insists on stderr cluttering up with progress information. If I do not read from stderr from time to time, the stderr buffer is full, and the process is delayed after a while.
Basically, I want to discard any output from stderr. My suggestions
1)
ffmpeg -i .... .... 2>/dev/null
This works, but means that I have to execute exec (String) instead of exec (String []), which means that I need to avoid my parameters, for which there is no standard function in Java. I could build one, but do not prefer.
2)
Use the ffmpeg command above in a shell script that redirects output to / dev / null. Sounds fine, but has a bash script only for what seems redundant.
3)
Attach ErrorStream, run a thread that does nothing but read () in the error stream. It will work, but it looks randomly ....
4) Use Apache Commons Exec ... I didnβt even check the documentation to see if this would work, but importing this whole library just for such a simple task doesnβt work either.
So basically my question is: is there a better way to do this? If not, which one do you consider [the strike] the most beautiful [/ strike] least ugly?
source share