0

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

Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
Milhous
  • 14,473
  • 16
  • 63
  • 82

1 Answers1

0

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

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • See also [When `Runtime.exec()` won't](http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html). – trashgod Jul 09 '11 at 04:09
  • See also [Java Tips: From `Runtime.exec()` to ProcessBuilder](http://www.java-tips.org/java-se-tips/java.util/from-runtime.exec-to-processbuilder.html). – trashgod Jul 09 '11 at 04:11