46
I have an application, running on the Playframework, which needs to encode some video files. I used
Process pr = Runtime.getRuntime().exec(execCode)
for this (and it works perfectly), but as I need both, the output stream and the error stream, I am trying to use ProcessBuilder (as is also recommended).
But I cannot get it to work (testing on a MacBook). Is there a fundamental difference between the Runtime method and the ProcessBuilder?
This is my code for ProcessBuilder (exactly the same code works when replaced by Runtime.getRuntime().exec())
String execCode = "/opt/local/bin/ffmpeg -i file [...]";
ProcessBuilder pb = new ProcessBuilder(execCode);
pb.redirectErrorStream(true);
pb.directory(new File("/Users/[...]/data/"));
Process pr = pb.start();
This is the console output:
11:00:18,277 ERROR ~ There was a problem with with processing MediaFile[13] with error Error during coding process: Cannot run program "/opt/local/bin/ffmpeg -i /Users/[...]/data/media/1/1/test.mov [...] /Users/[...]/data/media/1/13/encoded.mp3" (in directory "/Users/[...]/data"): error=2, No such file or directory
java.lang.Exception: Error during coding process: Cannot run program "/opt/local/bin/ffmpeg -i /Users/Luuk/Documents/Java/idoms-server/data/media/1/1/test.mov -y -f mpegts -acodec libmp3lame -ar 48000 -b:a 64000 -vn -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate -1 -bufsize -1 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -g 30 -async 2 /Users/Luuk/Documents/Java/idoms-server/data/media/1/13/encoded.mp3" (in directory "/Users/Luuk/Documents/Java/idoms-server/data"): error=2, No such file or directory
at logic.server.MediaCoder.encodeMediaFile(MediaCoder.java:313)
at logic.server