QtGStreamer不会从相机流式传输产生预期的输出

时间:2017-05-01 20:16:54

标签: gstreamer qtgstreamer

我正在尝试使用QtGStreamer来流式传输相机帧并将其渲染到QML窗口上。我有一个简单的Gstreamer管道,当我使用 <body ng-app='myApp'> <form id='form' ng-controller='logIn'> <h1>Log In</h1> <input type="text" id="username" placeholder="Enter Username" /> <input type="password" id="password"placeholder="Enter Password" /> <button id="button" type="button" ng-click='log()'>Click This</button> </form> <form id='form2' ng-controller='registerUser'> <h1>Register</h1> <input type='text' id='registerName' placeholder='Enter Username'/> <input type='password' id='registerPass' placeholder='Enter Password'/> <button id='registerButton' type='button' ng-click='place()'>Register</button> </form>

时它可以正常工作
gst-launch-1.0

现在我创建一个相应的QtGStreamer管道:

gst-launch-1.0 autovideosrc ! videoscale ! video/x-raw, width=480,height=270 ! xvimagesink -e

首先,这真的很慢。虽然原始gstreamer命令可以30帧/秒的速度轻松运行,但每秒运行几帧。当我设置void Streamer::startStreaming() { if (!m_streaming_pipeline) { m_streaming_pipeline = QGst::Pipeline::create(); if (m_streaming_pipeline) { QGst::ElementPtr source = QGst::ElementFactory::make("autovideosrc"); QGst::ElementPtr scale = QGst::ElementFactory::make("videoscale"); scale->setProperty("caps", QGst::Caps::fromString("video/x-raw, width=480,height=270")); if (m_videoSink) { m_videoSink->setProperty("sync", false); m_streaming_pipeline->add(source, scale, m_videoSink); source->link(scale); scale->link(m_videoSink); QGst::BusPtr bus = m_streaming_pipeline->bus(); bus->addSignalWatch(); QGlib::connect(bus, "message", this, &Recorder::onBusMessage); m_streaming_pipeline->setState(QGst::StatePlaying); qDebug() << "Done"; } } } }

时,我也会在控制台上获得此输出
GST_DEBUG=3

我注意到的另一件事是,渲染的帧,几乎是翻转颜色方案。因此,似乎沿线的某些东西也在翻转颜色通道。

修改

我发现我需要添加一个capsfilter才能获得正确的格式。所以添加如下内容:

0:00:08.661824920 23980      0x2ac6370 WARN          v4l2bufferpool gstv4l2bufferpool.c:540:gst_v4l2_buffer_pool_set_config:<autovideosrc0-actual-src-v4l:pool:src> libv4l2 converter detected, disabling CREATE_BUFS
0:00:08.665945185 23980      0x2ac6370 WARN          v4l2bufferpool gstv4l2bufferpool.c:748:gst_v4l2_buffer_pool_start:<autovideosrc0-actual-src-v4l:pool:src> Uncertain or not enough buffers, enabling copy threshold

然后通过

添加
QGst::ElementPtr capsfilter = QGst::ElementFactory::make("capsfilter", "capsfilter");
capsfilter->setProperty("caps", QGst::Caps::fromString("video/x-raw, width=1920, height=1080, format=RGB, framerate=30/1"));

随后链接它解决了问题。

虽然现在我的问题是gstreamer如何在我原来的管道中选择一个有效的格式?

0 个答案:

没有答案