Create and Run .bat file for FFMPEG code

I had issues getting FFMPEG to run from processing when I was trying to capture film frames. Hamoid suggested that I should use Process Builder in this post. In that he shared a really useful link to his code for the video export library.

Here’s a relevant excerpt of the code (probably with some rubbish you don’t need) that I ended up creating, hope this helps put you in the right direction:

void captureScaledFrames() {

  String[] commands = {
    ffmpegPath, 
    "-i", 
    path, 
    "-vf", 
    "\"scale=320:-1,fps=1/3\"", 
    "-vsync", 
    "0", 
    "-q:v", 
    "2", 
    sketchPath("Films/" + fileName + "/Frames/Scaled/out%07d.jpg")
  };
  captureProcess(commands);
}

void captureProcess(String[] cmds) {
  ProcessBuilder processBuilder = new ProcessBuilder(cmds);
  Process process;
  File ffmpegOutputLog;
  processBuilder.redirectErrorStream(true);
  ffmpegOutputLog = new File(dataPath(fileName+"_ffmpegLog.txt"));
  processBuilder.redirectOutput(ffmpegOutputLog);
  processBuilder.redirectInput(ProcessBuilder.Redirect.PIPE);
  try {
    process = processBuilder.start();
  } 
  catch (Exception e) {
    e.printStackTrace();
    println(ffmpegOutputLog);
  }
  tmr.start();
  capturing = true;
  //getCaptureProgress();
}