Unsolved Qprocess: howto run a command consisting of several commands chained together?
-
Hi All,
I'm writing a program that calls raspivid to record a video thru QProcess. This works great like this:
void ExternalCamera::slotStartCapture(QString filename) { if (myProcess->state() == QProcess::Running) { qDebug()<<"Process already Running, killing"; myProcess->kill(); myProcess->waitForFinished(10000); //qDebug()<<"Process Killed"; } qDebug()<<myProcess->state(); filename.append(".h264"); QStringList arguments; //arguments <<"-o" << "file.h264"; //filename arguments <<"-o" << filename; //filename arguments <<"-n"; //no preview arguments <<"--bitrate" << "1000000";//bitrate arguments <<"-t"<<"300000"; //time myProcess->setArguments(arguments); myProcess->setProgram("/usr/bin/raspivid"); myProcess->start(); qDebug()<<"start movie: "<<filename; myProcess->waitForStarted(10000); //qDebug()<<"Process started"; }
But now I would like to run the following command line. How can I tell QProcess to do this? Should I place this inside a .sh file, and then call the sh file?
raspivid -t 200000 -o test16.h264 ; avconv -framerate 30 -i test16.h264 -c:v copy test16.mp4
Cheers,
Cedric -
Hi,
So
avconv
should be called onceraspivid
is done, correct ? -
@cdwijs
You have 3 options!-
Split into two separate commands at the
;
. Run the left-hand side, wait to finish, run the right-hand side, as two differentQProcess
es. -
Put that command line into a file. Run
QProcess::execute("/bin/sh", QStringList() << "script.sh")
. -
Run the whole command-line as an argument to the shell:
QProcess::execute("/bin/sh", QStringList() << "-c" << "raspivid -t 200000 -o test16.h264 ; avconv -framerate 30 -i test16.h264 -c:v copy test16.mp4")`.
-