使用 OS X 在 java 中使用 Imagemajick
我使用 macports 在 OS X 中安装了 imagemajick。当我从命令行 (bash) 运行转换命令时,我可以将电影转换为 jpg。但是当我通过 Java Process Builder 运行它时,我没有得到这样的输出。什么给。以下是我用来执行该命令的java代码。
private void run(String[] args)
{
try
{
ProcessBuilder pb = new ProcessBuilder(args);
Process p = pb.start();
p.waitFor();
InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null)
{
System.out.println(line);
}
is = p.getErrorStream();
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
while ((line = br.readLine()) != null)
{
System.err.println(line);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
传入的字符串为 /usr/local/bin/convert /Users/me/Videos/Capture-20110708-220220.mpg[0] /Users/me/Videos/out0.jpg
I have imagemajick installed in OS X using macports. When I run a convert command from the command line (bash) I am able to convert my movie to a jpg. But when I run it via the Java Process Builder I get no such output. What gives. The following is the java code I use to execute the command.
private void run(String[] args)
{
try
{
ProcessBuilder pb = new ProcessBuilder(args);
Process p = pb.start();
p.waitFor();
InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null)
{
System.out.println(line);
}
is = p.getErrorStream();
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
while ((line = br.readLine()) != null)
{
System.err.println(line);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
The string passed in is /usr/local/bin/convert /Users/me/Videos/Capture-20110708-220220.mpg[0] /Users/me/Videos/out0.jpg
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试
redirectErrorStream()
,如相关的 示例,查看任何诊断输出。You might try
redirectErrorStream()
, as shown in this related example, to see any diagnostic output.