我在运行Ubuntu 14.04的nVidia TX1上使用qt-gstreamer 1.2和gstreamer 1.2.4。
我有一个带摄像头预览+录制+以太网流媒体+ Wifi流媒体的管道,我想让管道动态化。例如,我可以在正在运行的管道上添加/删除录制/流媒体。
我暂停管道添加/删除元素,然后在不使用pad及其阻塞功能的情况下恢复。这很好用。但是在几次添加/删除元素之后管道会挂起。当我暂停管道时,它会挂起。
我发现它的Pause / Resume挂起了管道,暂停时没有链接/取消链接元素。 如果我在管道中添加更少的元素,比如只添加预览和录制所需的元素,那么管道会在很长一段时间后挂起,然后挂起所有元素。
所有接收器元素同步和异步都是错误的。
m_pipeline = QGst::Pipeline::create();
m_source = QGst::ElementFactory::make("v4l2src", "v4l2src");
m_filter1 = QGst::ElementFactory::make("capsfilter", "capsfilter");
m_convert = QGst::ElementFactory::make("nvvidconv", "videoconvert");
m_filter2 = QGst::ElementFactory::make("capsfilter", "capsfilter1");
m_filter3 = QGst::ElementFactory::make("capsfilter", "capsfilter2");
m_tee = QGst::ElementFactory::make("tee", "tee");
m_tee1 = QGst::ElementFactory::make("tee", "tee1");
m_enc = QGst::ElementFactory::make("omxh264enc", "omxh264enc");
m_enc1 = QGst::ElementFactory::make("omxh264enc", "omxh264enc1");
m_parse = QGst::ElementFactory::make("h264parse", "h264parse");
m_parse1 = QGst::ElementFactory::make("h264parse", "h264parse1");
m_parse2 = QGst::ElementFactory::make("h264parse", "h264parse2");
m_mux = QGst::ElementFactory::make("qtmux", "qtmux");
m_filesink = QGst::ElementFactory::make("filesink", "filesink");
m_queue1 = QGst::ElementFactory::make("queue", "queue1");
m_queue2 = QGst::ElementFactory::make("queue", "queue2");
m_queue3 = QGst::ElementFactory::make("queue", "queue3");
m_queue4 = QGst::ElementFactory::make("queue", "queue4");
m_queue5 = QGst::ElementFactory::make("queue", "queue5");
m_queue6 = QGst::ElementFactory::make("queue", "queue6");
m_queue7 = QGst::ElementFactory::make("queue", "queue7");
m_queue8 = QGst::ElementFactory::make("queue", "queue8");
m_fakesink = QGst::ElementFactory::make("fakesink", "fakesink");
m_rtppay1 = QGst::ElementFactory::make("rtph264pay", "rtph264pay");
m_rtppay2 = QGst::ElementFactory::make("rtph264pay", "rtph264pay1");
m_udpsink = QGst::ElementFactory::make("udpsink", "udpsink");
m_udpsink1 = QGst::ElementFactory::make("udpsink", "udpsink1");
m_videoSink = QGst::ElementFactory::make("nvoverlaysink", "sink");
m_tee2 = QGst::ElementFactory::make("tee", "tee3");
m_fakesink1 = QGst::ElementFactory::make("fakesink", "fakesink1");
m_mux1 = QGst::ElementFactory::make("qtmux", "qtmux1");
m_filesink1 = QGst::ElementFactory::make("filesink", "filesink1");
m_filter1->setProperty("caps", QGst::Caps::fromString("video/x-raw, width=1920, height=1080, format=UYVY, framerate=60/1"));
m_filter2->setProperty("caps", QGst::Caps::fromString("video/x-raw(memory:NVMM), width=1920, height=1080, format=I420, framerate=60/1"));
m_filter3->setProperty("caps", QGst::Caps::fromString("video/x-h264, stream-format=(string)byte-stream"));
m_videoSink->setProperty("sync", false);
m_videoSink->setProperty("async", false);
m_pipeline->setProperty("video-sink", m_videoSink);
m_filesink->setProperty("sync", false);
m_filesink->setProperty("async", false);
m_enc->setProperty("bitrate", 19000000);
m_enc->setProperty("low-latency", 1);
m_enc->setProperty("control-rate", 2);
m_filesink->setProperty("location", "/home/ubuntu/video.mp4");
m_rtppay1->setProperty("mtu", 1400);
m_rtppay2->setProperty("mtu", 1400);
m_filesink1->setProperty("sync", false);
m_filesink1->setProperty("async", false);
m_filesink1->setProperty("location", "/home/ubuntu/video1.mp4");
m_udpsink->setProperty("port", 5000);
m_udpsink->setProperty("sync", false);
m_udpsink->setProperty("async", false);
m_udpsink->setProperty("host", "127.0.0.1");
m_udpsink1->setProperty("port", 8554);
m_udpsink1->setProperty("sync", false);
m_udpsink1->setProperty("async", false);
m_udpsink1->setProperty("host", "172.10.10.135");
m_pipeline->add(m_source, m_filter1, m_tee2, m_queue6, m_fakesink1);
m_pipeline->add(m_queue7, m_convert, m_filter2, m_tee, m_queue1, m_videoSink);
m_pipeline->add(m_queue2, m_enc, m_filter3, m_tee1, m_queue8, m_fakesink);
m_pipeline->add(m_queue3, m_parse, m_mux, m_filesink);
m_pipeline->add(m_queue4, m_parse1, m_rtppay1, m_udpsink);
m_pipeline->add(m_queue5, m_parse2, m_rtppay2, m_udpsink1);
m_pipeline->linkMany(m_source, m_filter1, m_tee2, m_queue6, m_fakesink1);
m_pipeline->linkMany(m_tee2, m_queue7, m_convert, m_filter2, m_tee, m_queue1, m_videoSink);
m_pipeline->linkMany(m_tee, m_queue2, m_enc, m_filter3, m_tee1, m_queue8, m_fakesink);
m_pipeline->linkMany(m_tee1, m_queue3, m_parse, m_mux, m_filesink);
m_pipeline->linkMany(m_tee1, m_queue4, m_parse1, m_rtppay1, m_udpsink);
m_pipeline->linkMany(m_tee1, m_queue5, m_parse2, m_rtppay2, m_udpsink1);
进行测试我每隔1秒暂停并播放管道。
m_pipeline->setState(QGst::StatePaused);
QThread::msleep(10);
m_pipeline->setState(QGst::StatePlaying);
管道在多次暂停/恢复后挂起。 如果我删除最后2行linkmany并添加我可以暂停/恢复多次,而不是添加所有元素。
那么这个问题到底是什么? 如何有效地暂停/播放管道?