We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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.
code:
import processing.video.*;
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) {
}
}
}
Answers
Check this post, it might help: https://forum.processing.org/two/discussion/comment/87325/#Comment_87325
Kf
How can I get it to put the .bat file where I want it, not where the video is? I've tried
and
and it tells me
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?
thanks.
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.
Kf