大佬们,能不能说一下为什么这样啊 java
public class TestApp {
public static void main(String[] args) throws IOException, InterruptedException {
ProcessBuilder processBuilder = new ProcessBuilder("D:\\ffmpeg\\bin\\ffmpeg.exe", "-i", "D:\\test\\test.mp4",
"-strict", "-2", "-vf", "crop=280:360:0:0", "D:\\test\\out.mp4"
);
Process process = processBuilder.start();
process.waitFor();
}
}
python
os.system("D:\\ffmpeg\\bin\\ffmpeg.exe -i D:\\test\\test.mp4 -strict -2 -vf crop=280:360:0:0 D:\\test\\out.mp4")
1
xl224 2020-10-18 12:25:33 +08:00 via iPhone 1
把 stdout 和 stderr 读出来,也可以设置转发 err 到 stdout 然后一起读取出来,不读取如果写满缓冲会挂起程序,ffmpeg 我记得会有大量输出信息
|
2
paulluis2dev 2020-10-18 12:49:59 +08:00 via iPhone
没用对,说明不了问题
|
3
qwertty01 OP @xl224 大佬这样写行吗?
``` Process process = processBuilder.start(); byte[] bytes = new byte[104]; while (true) { if (process.getInputStream().read(bytes) != -1) { System.out.println(bytes.toString()); } else { break; } } ``` |
4
lxk11153 2020-10-18 13:27:24 +08:00
-y (global)
Overwrite output files without asking. |
5
chihiro2014 2020-10-18 13:29:16 +08:00
= =说起来,我服务端也是用 Java 调用 ffmpeg,完全没这种问题
|
6
lxk11153 2020-10-18 13:40:29 +08:00
-strict 拿来干嘛的?
---- try(InputStream pis=process.getInputStream()){ // org.apache.commons.io.IOUtils#toString(InputStream, Charset) } |