Quantcast

QtGStreamer not producing expected output on streaming from camera

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

QtGStreamer not producing expected output on streaming from camera

xargon
This post was updated on .
I am trying to use QtGStreamer to stream camera frames and render it onto a QML window. I have a simple Gstreamer pipeline which works fine when the I use `gst-launch-1.0`

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

Now I create a corresponding QtGStreamer pipeline as:

    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";
                }
            }
        }
    }

So first off, this is really slow. While the original gstreamer command runs easily at 30 frames/second, this is running at a couple of frames per second. I also get this output on the console when I set `GST_DEBUG=3`

    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

Another thing I npticed is that the frames that do get rendered, it is almost that the color scheme is flipped. So, it seems that something along the line is also flipping the colour channels.

EDIT

I figured out that I needed to add a capsfilter to get the correct format. So adding something like:

    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"));

and then adding it via

   
m_streaming_pipeline->add(source, capsfilter, scale, m_videoSink);

and subsequently linking it solved the problem.

Although now my question is how does gstreamer pick a valid format in my original pipeline?



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: QtGStreamer not producing expected output on streaming from camera

xargon
I figured out that I needed to add a capsfilter to get the correct format. So adding something like:

    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"));

and then adding it via

   
m_streaming_pipeline->add(source, capsfilter, scale, m_videoSink);

and subsequently linking it solved the problem.

Although now my question is how does gstreamer pick a valid format in my original pipeline?

Loading...