从 Java 的 processbuilder 执行的 ffmpeg 在 windows 7 下不返回
我试图构建一个调用 ffmpeg 二进制文件的 ProcessBuilder.我的问题是调用它,它在 MacOs、Ubuntu 和 WindowsXp 下完美返回,但在 Windows7 下,waitFor() 永远不会返回.
I was trying to build up a ProcessBuilder calling the ffmpeg binary. My problem is that calling it, it returns perfectly under MacOs, Ubuntu and WindowsXp, but under Windows7 the waitFor() never returns.
有没有人在windows 7下有类似的经历?任何帮助将不胜感激!
Has anyone similar experience under windows 7? Any help would be appreciated!
我的命令:
ProcessBuilder pb = new ProcessBuilder( );
pb.command( "C:\Windows\System32\cmd.exe", "/c", "c:\ffmpeg\bin\ffmpeg.exe", "-version" );
也试过这些:
pb.command( "c:\ffmpeg\bin\ffmpeg.exe", "-version" );
pb.command( "C:\Windows\System32\cmd.exe", "/c", "start c:\ffmpeg\bin\ffmpeg.exe -version" );
结果是一样的.:(
推荐答案
看起来您的进程在其输出和/或错误流中写入了一些内容.他们的缓冲区溢出和进程阻塞.您应该读出并错误处理您的流程以避免这种情况.
Looks like your process writes something in its out and/or err streams. Their buffer overflow and process blocks. You should read out and err streams of your process to avoid this.
请参阅当 Runtime.exec() 获胜时"t"了解更多信息
相关文章