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.

1 Answer 1

2

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

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

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

2 Comments

Or use Apache Commons Exec (this question can help: stackoverflow.com/questions/2693020/…)
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.

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.