Reputation: 283
I'm currently running a ffmpeg process in java using:
Process ffmpeg = new ProcessBuilder("ffmpeg", ...).start();
ffmpeg.waitFor();
The issue is this process never terminates. However, if I do:
ProcessBuilder ffmpeg = new ProcessBuilder("ffmpeg", ...);
ffmpeg.redirectErrorStream(true).redirectOutput(ProcessBuilder.Redirect.INHERIT);
ffmpeg.start().waitFor();
The process runs fine.
Does anyone know why this might happen? It seems extremely weird that a process won't proceed unless I read its output.
Upvotes: 0
Views: 250
Reputation: 73528
It's perfectly normal. There's a limited sized output buffer that needs to be read (or redirected to a bitbucket).
It's also one of the most common pitfalls when people start using ProcessBuilder
and don't read the documentation first ;)
Upvotes: 5