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:
- [PROJECT] itdage java to get the weather and send text messages
- Java parsing xml file encounters special symbols & will be abnormal solutions
- [Solved] Java.lang.IllegalStateException: getReader() has already been called for this request
- CreateProcess error = 5, access denied. [How to Solve]
- How to convert a Java string into a number (stringtonumber)
- JAVA 8: How to Convert List to Map
- Comparison between ArrayList and HashMap
- Exception information: jsonmappingexception: out of start_ ARRAY token
- How to get the current time in java time string
- [How to Fix]Spring 3.0 could not find acceptable representation
- Java — for loop printing graphics (loop structure)
- Java: How to Find the Minimum Value from a Random Array by Bubble Sort Method
- Java error prompt….. cannot be resolved
- The problem of date format conversion between springboot and front end
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘testApplicat
- RSA Decryption Error: java.security.InvalidKeyException: IOException : algid parse error, not a sequence
- How to Use filechannel to copy files
- Mongodb java version 3.X, prompt “XXX (an encryption algorithm) is not available” when there is a user name and password
- Multipartfiletofileutils (multipartfile to file)
- How to Solve JVM Common Errors: outofmemoryerror & stackoverflowerror