0

I have an application written in java that needs read videos from a directory and convert them using ffmpeg. I already have ffmpeg installed on my pc and i want use it in my program using "ProcessBuilder", here a sample code:

List<String> cmds =  new ArrayList<>();
cmds.add("ffmpeg");
cmds.add("-i");
cmds.add("video1.avi");
cmds.add("video2.mp4");
cmds.add("-hide_banner");
ProcessBuilder pb = new ProcessBuilder(cmds);
Process p = pb.start();
p.waitFor();

The ffmpeg process is created and as expected my app is blocked until ffmpeg process finish its job, but the process never finish, it create a file with 2mb of size and then pause the convertion, and never finish, when i kill my java application the ffmpeg process continue the convertion, i need wait for the completion of the task and notify that the convertion is finished, any idea?, thanks

  • you might try dumping stdout from the new process so that you can see what is going during the ffmpeg process getting hung up.... https://stackoverflow.com/questions/14165517/processbuilder-forwarding-stdout-and-stderr-of-started-processes-without-blocki – Robert Rowntree Apr 16 '18 at 21:24
  • Use `pb.inheritIO();` before starting the process, to see its output. – VGR Apr 17 '18 at 00:40

1 Answers1

0

Its better to use Runtime.getRuntime().exec()! It will works, I am using that way. it works better and directly to the command prompt !!

SGarcia
  • 13
  • 6