2

I am trying to evoke FFMPEG directly in my Java code (running under the Playframework!). The final product will run on a Linux/Debian distro, but I first need to test on my Mac (I don't know if it works on Debian yet).

I try to execute the simple code:

Process pr = Runtime.getRuntime().exec(new String[]{"bash","-c", "ffmpeg"});

or simpler:

Process pr = Runtime.getRuntime().exec("ffmpeg")

or using ProcessBuilder:

Process pr = new ProcessBuilder("/opt/local/bin/ffmpeg").start();

What I get is an error code 133, but I cannot find what this means. In the terminal the command gives the normal output. I can also replace 'ffmpeg' with e.g. 'ls -la' and get the directory listing. But I don't know what the problem is that ffmpeg does not work.

Anybody any clues? Thanks!

UPDATE: I looked at the error stream. These are the errors I get. How is it that it works in the terminal, but not in using Java?

14:43:19,619 DEBUG ~ FFMPEG: dyld: Library not loaded: /opt/local/lib/libogg.0.dylib
14:43:19,619 DEBUG ~ FFMPEG:   Referenced from: /opt/local/bin/ffmpeg
14:43:19,619 DEBUG ~ FFMPEG:   Reason: Incompatible library version: ffmpeg requires version 9.0.0 or later, but libogg.0.dylib provides version 6.0.0
7
  • See When Runtime.exec() won't, and for 1.5+ use a ProcessBuilder to make things easier. But why not use jffmpeg instead? I am guessing it has better ways to interface with the API than invoking a new Process. Commented Apr 29, 2012 at 13:27
  • I think that this is a problem with loaded shared libraries. Do remember that when you use exec() you don't have all the ENV variables you usually have when in a terminal (user specific in bash.rc for example). Read from the standard error stream to track down the problem. Commented Apr 29, 2012 at 13:28
  • What's the result of Runtime.getRuntime().exec("/fully/qualified/path/to/ffmpeg") Commented Apr 29, 2012 at 13:32
  • jffmmpeg has not been updated for 7 years. I will look at ProcessBuilder. Commented Apr 29, 2012 at 13:34
  • Runtime.getRuntime().exec("/fully/qualified/path/to/ffmpeg") renders the same result Commented Apr 29, 2012 at 13:37

1 Answer 1

2

I used Xuggle for my video encoding and it happened to include an older version and is in the class path. Even though the link shown is from the newer, it used the older.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.