问题
I'm trying to open a process (ffmpeg) using the Java ProcessBuilder. So far so good but I can't really pass any arguments to the process.
The ProcessBuilder just won't use the right arguments.
Here's my code so far:
ProcessBuilder builder = new ProcessBuilder("ffmpeg/ffmpeg.exe", "-i " + this.inputFile.getAbsolutePath(), "-c:v libvpx", "-minrate " + iBitrate + "k", "-maxrate " + iBitrate + "k", "-b:v " + iBitrate + "k", "-c:a libvorbis", this.outputFile.getAbsolutePath());
A sample output I got:
Unrecognized option 'i D:\Noneatme\Dokumente\AAAAAAAAAAAA\day.mp4'.
Error splitting the argument list: Option not found
I never said "i" or anything like that, am I doing something wrong?
回答1:
Remove the space after -i
in the 2nd parameter of the ProcessBuilder constructor, and make this.inputFile.getAbsolutePath()
the 3rd parameter to the ProcessBuilder constructor. Don't add it to "-i"
. Essentially, make sure each element separated by spaces are their own arguments to the ProcessBuilder constructor.
来源:https://stackoverflow.com/questions/28074670/process-builder-wont-accept-ffmpeg-arguments