# Create and Run .bat file for FFMPEG code

**URL:** <https://discourse.processing.org/t/create-and-run-bat-file-for-ffmpeg-code/33482>\
**Category:** Coding Questions\
**Created:** [November 13, 2021, 12:18am UTC](https://discourse.processing.org/t/create-and-run-bat-file-for-ffmpeg-code/33482 "2021-11-13T00:18:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![tribblesontoast](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tribblesontoast](https://discourse.processing.org/u/tribblesontoast)\
**Post date:** [November 13, 2021, 2:18am UTC](https://discourse.processing.org/t/create-and-run-bat-file-for-ffmpeg-code/33482/2 "2021-11-13T02:18:19Z")

</div>

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](https://discourse.processing.org/t/monitoring-process-of-ffmpeg-in-processing/17950/7). 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:

```auto
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();
}

```

---

_[View the full topic](https://discourse.processing.org/t/create-and-run-bat-file-for-ffmpeg-code/33482)._
