简体   繁体   中英

Runtime.getRuntime.exec() problem

hi I am trying to execute the Runtime.getRuntime.exec("ffmpeg -i inputfile image2 imagefile");

the input file in my code is the video file and i'm selecting the video file through the GUI

and i store it in a variable.So how can i use a variable name in place of the String?.It does

not work if i substitute the variable. Any help is greatly app

String inputfileVariable = ...; << maybe you calculate, maybe get from some GUI component
Runtime.getRuntime.exec("ffmpeg -i " +  inputfileVariable + " image2 imagefile");

There's no magic here, it's only a string.

You need command array like this:

// i guess that ffmpeg is a command name and the reset are arguments
Runtime.getRuntime().exec(new String[] {"ffmpeg","-i",inputfileVariable,"image2", "imagefile"});

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