system("ffmpeg...") returns immediately

I have to implement some ffmpeg routines as soon as possible. Best would be to use the libav directly. But it's yet not possible (needs time). In the meantime I want to implement the calls with system("ffmpeg ..."). This works, but the system call returns (nearly) immediately. The started ffmpeg process itself runs much longer. Now I am deleting the source files after the ffmpeg call. But what happens: ffmpeg still runs and I am just deleting the sources files...
Is this a typical ffmpeg problem or the basic system() behavior? As I know system() should wait until the process ends...
Any change to wait for ffmpeg ends execution?

Working on Ubuntu 10.04.
Code snippet:

system("ffmpeg -image2 -i /home/user/pics/mypics%04d.jpg /home/user/vids/myvideo.avi");
system("rm -f /home/user/pics/mypics*.jpg");

P.S. It seems to be the same behavior in perl...
It sounds like ffmpeg forks() itself, lets the parent exit immediately and does all the work on the child process. (ie, it
essentially backgrounds itself).

Is there are option on ffmpeg to turn that behavior off?
Thx for you answer.
I debugged the code again and finally found a bug in the ffmpeg call itself. I only converted the last of the pic(s) in my input sequence which made it so fast. It seemed to be obvious that the system call for ffmpeg returned immediately.
So everything works fine with system() and ffpmeg.

Btw, calling
system("gedit");
(without &) really returns immediately and my (test) program finishes while gedit remains open.
Last edited on
Try using popen rather than system and see if that makes any difference.
Topic archived. No new replies allowed.