简体   繁体   中英

qt create gst-launch process

I am trying to create gst-launch process with this pipeline:

gst-launch -ve videotestsrc ! 'video/x-raw-yuv,width=640,height=480,framerate=15/1,format=(fourcc)I420' ! queue ! mfw_vpuencoder codec-type=2 ! queue ! avimux name=mux ! filesink location=sd/Video/1.avi

I tried to use qprocess to run this pipeline. But I failed at the end. Some of my attempts to run gst-launch are below:

process->start("gst-launch -ve videotestsrc ! 'video/x-raw-yuv,width=640,height=480,framerate=15/1,format=(fourcc)I420' ! queue ! mfw_vpuencoder codec-type=2 ! queue ! avimux name=mux ! filesink location=sd/Video/1.avi");

QStringList args = QString("-ve videotestsrc ! 'video/x-raw-yuv,width=640,height=480,framerate=15/1,format=(fourcc)I420' ! queue ! mfw_vpuencoder codec-type=2 ! queue ! avimux name=mux ! filesink location=sd/Video/1.avi").split(" ");
process->start("gst-launch", args);

When invoked by a shell the quotes (and double-quotes) are used to lump multiple words into a single argument, but the quotes are also discarded. It's possible that including the quotes in your arguments is causing your errors.

Therefore this would be closer (I've removed the ' characters):

QStringList args = QString("-ve videotestsrc ! video/x-raw-yuv,width=640,height=480,framerate=15/1,format=(fourcc)I420 ! queue ! mfw_vpuencoder codec-type=2 ! queue ! avimux name=mux ! filesink location=sd/Video/1.avi").split(" ");
process->start("gst-launch", args);

I believe this will work in your case, however that's only because none of the arguments contains spaces, which would need to be quoted.

Better, but more tedious, would be to manually create the argument list, one string at a time if you ever want to use arguments containing spaces:

QStringList args;
args << "-ve" << "videotestsrc" << "!" << "video/x-raw-yuv,width=640,height=480,framerate=15/1,format=(fourcc)I420" << etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM