4

I have simple test class as

public static void main(String[] args) throws IOException {

         String[] line = {"ffmpeg -i D:\\hadoop-video\\testVideo\\xyz.mp4 %d.png"};
         Runtime.getRuntime().exec(line);

    }

when I try to run this I am getting

Exception in thread "main" java.io.IOException: Cannot run program "ffmpeg -i D:/hadoop-video/testVideo/xyz.mp4 %d.png": CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at ImageTest.main(ImageTest.java:13)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified

however file is present on my windows7 machine with location

D:\hadoop-video\testVideo\xyz.mp4

i tried removing .mp4 and then run also not working . please suggest what might be wrong

1

1 Answer 1

2

Where ffmpeg.exe is installed? try to use full path to execute the ffmpeg.exe

e.g.

D:\ffmpeg\bin\ffmpeg.exe

then

String cmd[] = {"D:\\ffmpeg\\bin\\ffmpeg","-i","D:\\ffmpeg\\hadoop.mp4","D:\\ffmpeg\\img%d.png"};
Runtime.getRuntime().exec(cmd);

or

Process process = new ProcessBuilder(Arrays.asList(cmd)).start();
Sign up to request clarification or add additional context in comments.

5 Comments

I added full path as below String[] line = {"C:\\Program Files\\ffmpeg\\bin\\ffmpeg.exe -i D:\\hadoop-video\\testVideo\\xyz.mp4 %d.png"}; Runtime.getRuntime().exec(line); still not working .
error i am getting is as Cannot run program "C:\Program Files\ffmpeg\bin\ffmpeg.exe -i D:\hadoop-video\testVideo\xyz %d.png": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at ImageTest.main(ImageTest.java:14)
String[] line = {"C:\\Program Files\\ffmpeg\\bin\\ffmpeg", "-i", "D:\\hadoop-video\\testVideo\\xyz", "%d.png"}; Runtime.getRuntime().exec(line); Now no error is coming however Images are also not getting generated
Check your project directory in eclipse workspace, this will have all generated images ;)
Hey Thanks .. its there in Eclipse . i was trying to search in the video folder ..Can we customize the location . thanks one more time :) cheers

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.