Launching ffmpeg from ofSystem()

I am on windows and want to use ffpmeg to record some audio in the background while my app is running. I want to use ffmpeg as I assumed it would run in its own thread while my ofApp runs. I dont need the audio inside or from my ofApp, I just want an mp3 of the audio recorded from the mic from time to time.

I have an ffmpeg command working fine, but I was surprised to see that my app stops and is unresponsive as soon as I start the recording using ofSystem().

I know that ofxVideoRecorder does something similar and more complex, but I cannot get it working on windows and dont need the functionality.

Is there a way I can runn the ffmpeg command without blocking my app?

I use ffmpeg on win very often and it works. Just call it in threaded function.
This is a pseudo code:

class ofxThreadedYourClass: public ofThread {
...

void start() {
	startThread();
}

void threadedFunction() {
	stringstream someCmd;
    //build ffmpeg command
   someCmd << ffmpegLocation << " -i \"" << filePath << fileName << ...
   system(someCmd.str().c_str());
}

from ofApp call yourClassObject.start()

Amazing, @SebastianSobotka any clues on how to stop a recording? Sending “q”, which works as a keystroke does not seem to work.

Using ofSystem("taskkill /im ffmpeg.exe /t /f");
Gives me a corrupt file.

I think it could be difficult because of thread function. Normally as I know you can just use ctrl+c or ‘q’ and it stops a process. I don’t know how to pass it to threaded function. Killing the process doesn’t properly close the movie. It should be another method to do this properly, take a look at ofxVideoRecorder addon and maybe you can find something.

I think this is your case:
https://trac.ffmpeg.org/ticket/6336

and this is some kind of workaround:
http://autosqa.com/blog/index.php/2016/03/24/how-to-record-windows-desktop-with-ffmpeg/