1

I am developing a Red5 media server application on a Mac (Dynamic Web Project in Eclipse). The app has to invoke FFMPEG to convert the video to a different format.

I added "/Applications/FFMPEG" to PATH variable by running the following command in Terminal:

echo 'export PATH=/Applications/FFMPEG:$PATH' >> ~/.profile

When I invoke FFMPEG from terminal, it works fine. However, every time I run it from Java code with:

Process p = Runtime.getRuntime().exec("ffmpeg");
p.waitFor();

I get the following error:

Cannot run program "ffmpeg": error=2, No such file or directory

I thought this might be a security limitation specific to the type of project, but even a simple Java program produces the same result. What am I missing?


Changing "ffmpeg" to full path of the application works, but I don't want to upload FFMPEG into the same directory as Red5 on a production server.

ldwii
  • 112
  • 7

1 Answers1

2

PATH is a command prompt thing. Java knows nothing about paths.

Specify the full path (ie the absolute path) of your executable

Bohemian
  • 412,405
  • 93
  • 575
  • 722
  • Or use Apache Commons Exec (this question can help: http://stackoverflow.com/questions/2693020/commons-exec-executing-a-program-on-the-system-path) – Jason Sperske Nov 17 '12 at 00:19
  • Thank you for explanation. I tried commons-exec, and 'EnvironmentUtils.getProcEnvironment();' shows that the PATH variable is unchanged, while 'echo $PATH' in Terminal shows newly included directory. – ldwii Nov 17 '12 at 05:54