ArrayList<String> convert = new ArrayList<String>();
convert.add("ffmpeg -y -i C:/Users/fang/Desktop/1.m4a -ar 8000 -acodec mp3 C:/Users/fang/Desktop/5.mp3");
ProcessBuilder builder = new ProcessBuilder();
try {
builder.command(convert);
// If this property is true, any error output generated by subsequent child processes started by the start() method of this object will be merged with the standard output.
// so both can be read using the Process.getInputStream() method. This makes it easier to associate error messages with the corresponding output
builder.redirectErrorStream(true);
Process process = builder.start();
InputStream is = process.getInputStream();
InputStreamReader inst = new InputStreamReader(is, "GBK");
BufferedReader br = new BufferedReader(inst);//Input stream buffer
String res = null;
StringBuilder sb = new StringBuilder();
while ((res = br.readLine()) ! = null) {//Loop through the data in the buffer
sb.append(res + "\n");
}
System.out.println(sb.toString());
} catch (Exception e) {
mark = false;
System.out.println(e);
e.printStackTrace();
} finally {
}
Solution:
The commands in processbuilder must be specified by full path, otherwise an error will be reported.
D:\\softwares\\ffmpeg-4.4.1-essentials_build\\bin\\ffmpeg.exe -y -i C:/Users/fang/Desktop/1.m4a -ar 8000 -acodec mp3 C:/Users/fang/Desktop/5.mp3
Read More:
- CreateProcess error = 5, access denied. [How to Solve]
- easy-pdf-merge Error: java: command not found [How to Solve]
- [Solved] Hibernate Error: java.lang.StackOverflowError at java.lang.Integer.toString(Integer.java:402)
- Feign calls cannot use “_” to report errors [How to Solve]
- Run hadoop fs -put Command Error: java.io.IOException: Got error, status message , ack with firstBadLink
- [Solved] Mac Maven Command Error: zsh: command not found
- [Solved] Command line is too long. Shorten command line for XXXXXXXTest.rmLogRecordOver Error running
- Executing Maven command error: Java_HOME is not defined correctly executing maven
- Springboot startup error: err config is disabled command (Redis Disables Config command)
- [Solved] Error running ‘ServiceStarter’: Command line is too long. Shorten command line for ServiceStarter or also for Application default configuration
- [Solved] IDEA Start Project Error: Error running ‘xxxxxx‘: Command line is too long. Shorten command line for …..
- [Solved] error running ‘xx‘ Command line is too long shorten command line for xx or also for Spring Boot defa
- Project Startup Error: Error running ‘xxxApplication‘;Command line is too long, Shoerten command line for……..
- [PROJECT] itdage java to get the weather and send text messages
- [Solved] IDEA java compile error: Error:java: Compilation failed: internal java compiler error
- [Solved] JAVA OpenCV Startup Error: java.lang.UnsatisfiedLinkError
- [Solved] Java 9 reflection error: java.lang.reflect.InaccessibleObjectException
- [Solved] java Internal error in the mapping processor java.lang.NullPointerException
- [Solved] java Internal error in the mapping processor java.lang.NullPointerException
- [Solved] java: Internal error in the mapping processor: java.lang.NullPointerException