简体   繁体   中英

executing Runtime.getRuntime.exec(String cmd)

Hi I am trying to execute the command string with Runtime.getRuntime.exec(String cmd).What

i'm actually trying to extract the I frames from video using the MPlayer and it is

installed in the different directory than that of my eclipse workspace.

I'm using the java code like the below

C:\\\Program Files\\\MPlayer for Windows mplayer file.mp4 -benchmark   -noframedrop -ao null -vo jpeg:outdir=iframes  -vf  framestep=I

the actual command to extract using DOS is

"mplayer file.mp4 -benchmark   -noframedrop -ao null -vo jpeg:outdir=iframes  -vf  framestep=I".

The ECLIPSE WORKSPACE is in my d: drive.And the Mplayer is in c:\\program files\\Mplayer for windows.

Eclipse IDE shows the exception as:-

Exception in thread "main" java.io.IOException: Cannot run program "C:\Program Files\MPlayer for Windows": CreateProcess error=5, Access is denied
    at java.lang.ProcessBuilder.start(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at myvideo1.main(myvideo1.java:39)

Any help is greatly appreciated.

Try this:

exec("\"C:\\Program Files\\MPlayer for Windows\\mplayer\" file.mp4 -benchmark   -noframedrop -ao null -vo jpeg:outdir=iframes  -vf  framestep=I");

I surrounded the command in \\" since the path contains spaces and added a missing \\ in front of mplayer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM