java - ffmpeg process saying it is erroring -
i using ffmpeg convert audio file. call command line , in turn ffmpeg java. using runtime , process runtime.exec(). process have inputstream , errorstream. reason, though ffmpeg commands works fine, prints out error stream giving impression has failed. know why might happening? it's not major issue work fine, if reason error, or new project not realise how works confusing. ideas? here relevant code:
runtime rt = runtime.getruntime(); system.out.println("execing " + cmd); process proc = rt.exec(cmd); streamgobbler errorgobbler = new streamgobbler(proc.geterrorstream(), "error"); // output? streamgobbler outputgobbler = new streamgobbler(proc.getinputstream(), "output"); // kick them off errorgobbler.start(); outputgobbler.start(); // error??? int exitval = proc.waitfor(); system.out.println("exitvalue: " + exitval);
and streamgobbler class:
class streamgobbler extends thread { inputstream is; string type; streamgobbler(inputstream is, string type) { this.is = is; this.type = type; } public void run() { try { inputstreamreader isr = new inputstreamreader(is); bufferedreader br = new bufferedreader(isr); string line = null; while ((line = br.readline()) != null) system.out.println(type + ">" + line); } catch (ioexception ioe) { ioe.printstacktrace(); } }
what experiencing standard practice across *nix tools: send "business value" data stdout
, separately send diagnostic output stderr
. important hallmark of tools written in "small beautiful" paradigm, values concept of piping 1 tool's output next one's input, thereby creating ad-hoc chain of information processing. complete scheme break down if tool sent "processing... 50% done" kind of output stdout
.
feel free ignore such output on stderr
, make sure consume it, doing now, in order avoid blocking due overfull output buffers.
Comments
Post a Comment