开发者

Using Imagemajick in java using OS X

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);

              开发者_Python百科  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


You might try redirectErrorStream(), as shown in this related example, to see any diagnostic output.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜