Let me start off by saying that I'm completely new to Java. I'm from PHP background, but it so happens that one of my PHP tasks need to be converted into Java.
The task is splitting a video into frames using ffmpeg and then working with those frames. I've completed this process in PHP. And now I can to convert it into Java.
I went over some tutorials and have got the bases covered (Using IDE, Running a java program etc). I'm using Eclipse for this purpose.
I've so far managed to start ffmpeg from withing a java program by using
public static void main(String[] args) throws IOException {
String livestream = "D:/video.mpg";
String folderpth = "D:/frames";
String cmd="D:/ffmpeg/bin/ffmpeg.exe -i "+ livestream +" -r 10 "+folderpth+"/image%d.jpg";
//System.out.println(cmd);
Runtime r = Runtime.getRuntime();
Process p = r.exec(cmd); // this starts creating frames
// and stores them on local disk
// any way to store that frame name in array?
// something like String[] frames = {"image%d.jpg"}
// so that frames array contains image1.jpg, image2.jpg..and so on?
}
This is working fine, I'm getting the frames in the folder. Now what I want to do is kill the process after some, say 5 minutes, as the video is over 2 hours long and I don't want to have to go to the taskbar and kill the process manually. I also would like to know if there is a way to store the frame names created by ffmpeg into an array for future use.
I tried using p.destroy()
but that didn't stop the process at all. How would I go about using something similar like setTimeout()
which is used in jQuery?
Some Metadata
OS : Windows 7
IDE : Eclipse