0

I have following code:

proc = new QProcess();
proc->startDetached("C:\\ffmpeg.exe", QStringList() <<"-i"<< "C:\\pics\\frame%d.png"<< "-r"<< "30" << "-vcodec"<< "ffv1" << "C:\\test.avi" );
connect(proc,SIGNAL(finished(int)),this,SLOT(finishedFFMPEG(int)));

For some reason the SIGNAL for finished() and started() never gets called. The test.avi file is being created correctly.

What am I missing here?

testus
  • 183
  • 2
  • 21

1 Answers1

0

QProcess::startDetached is a static function. It has no effect on the instance of QProcess.

Use QProcess::start instead.

Also the backslashes in "C:\pics\frame%d.png" should be escaped, or even better use slashes ("C:/pics/frame%d.png") or a C++11 raw literal(R"(C:\pics\frame%d.png)").

sbabbi
  • 11,070
  • 2
  • 29
  • 57
  • QProcess::start is not doing anything for some reason. QProcess::startDetached runs the process correctly but none of the signals for finished() and started() are being called – testus Apr 14 '15 at 17:42
  • @testus Because `startDetached` has nothing to do with `proc`. It is a static function. The proper syntax should be: `QProcess::startDetached( ... ) `. It leaves your `proc` unaffected. Hence the signals will never be emitted. – sbabbi Apr 14 '15 at 17:44
  • Ok, I get that but how come `proc->start("C:\\ffmpeg.exe", QStringList() <<"-i"<< "C:\\pics\\frame%d.png"<< "-r"<< "30" << "-vcodec"<< "ffv1" << "C:\\depth.avi" );` is not doing anything? – testus Apr 14 '15 at 17:47
  • Check it it emits the `started` signal. – sbabbi Apr 14 '15 at 17:50
  • It doesn't. I found out that if I create a QProcess object instead of QProcess* it will emit the signals. But I can't use QProcess in my case – testus Apr 14 '15 at 17:58
  • That doesn't seem to be the right signature for the signal finished - it emits (int, QProcess::ExitStatus), not just int. You should check the result of connect(), always. And check the debug output as connect() will complain in the debug output if it couldn't make the connection you ask. – Hamish Moffatt Apr 15 '15 at 02:03
  • Or use the new Qt5 connect() syntax where you would get a compile error if you screw up the arguments. – Hamish Moffatt Apr 15 '15 at 02:04