Launching ffmpeg from cmd in sketch?

Hi all, As the title says, i'm trying to launch ffmpeg, which is a command line utility, from within a sketch. I've tried exec(), and open() and launch(), with no real success that I can see. The code below prints "the process returned 1" to the processing console, but the command line is never launched.

What do I need to do to make this work?

Thanks in advance.


Movie mov;
String fileName;

void setup() {
  size(800, 800);

void draw() {

void keyPressed() {
  if (key == 'p') selectInput("Select movie:", "movieSelected");

void movieSelected(File selection) { 
  if (selection == null) {
    println("Window was closed or the user hit cancel.");
  } else {
    fileName = selection.getAbsolutePath();
    mov = new Movie(this, fileName);

    String[] processCommands = {
      "E:/Tertiary/COMP390/Movie Second/ffmpeg/bin/ffmpeg.exe", 
      "ffmpeg", "-i", "mov", "-codec:a", "libmp3lame", "-qscale:a 2", "fileName" + "output.mp3"
    Process p = launch(processCommands);

    try {
      int result = p.waitFor();
      println("the process returned " + result);
    catch (InterruptedException e) {


  • How can I get it to put the .bat file where I want it, not where the video is? I've tried

        output = createWriter(dataPath("") + "\\" + fileName + "\\" + fileName + "audioCapture.bat");


        output = createWriter(sketchPath("")yadda yadda...);

    and it tells me

    Caused by: java.lang.RuntimeException: Couldn't create a writer for E:\Development\CommandLineCallII\data\E:\Video\Hellboy\Hellboy-vs-Sammael.mp4_AudioCapture.bat
    Caused by: E:\Development\CommandLineCallII\data\E:\Video\Hellboy\Hellboy-vs-Sammael.mp4_AudioCapture.bat (The filename, directory name, or volume label syntax is incorrect)

    also, when I get it to launch the command prompt, its filepath is always


    and nothing I put in the .bat file will convince it otherwise. How can I set its path?


  • Don't use dataPath or sketchPath, but absolute paths. I think there is a discussion about it in loadStrings or createWriter in the reference page.


Sign In or Register to comment.