Tuesday, May 11, 2010

Using ProcessBuilder in java to run FFMPEG command to create thumbnail

String dimension = iThumbnailHeight+"X"+iThumbnailWidth;


ProcessBuilder pb = new ProcessBuilder(pathToFFMPEG,"-i",pathToSrcFile, "-s",dimension,"-ss","00:00:01.00","-vcodec","mjpeg","-vframes","1","-f","image2",tempFilePath);

pb.redirectErrorStream(true);

System.out.println("---------"+pb.command());

Process p = pb.start();

BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));

String line = null;

while((line=br.readLine())!=null){

System.out.println("---------"+line);

}

System.out.println("----wait over--- "+p.waitFor());
Note: Notice number of argumants to ProcessBuilder Constructor . You should same number of arguments , as command line input options. Check each  option is send separately as argument.

No comments: