Freescale / gstreamer-imx

GStreamer 1.0 plugins for i.MX platforms
Other
184 stars 127 forks source link

i.mx6 + qmlsink = VIDIOC_DQBUF failed: Timer expired #298

Closed R3D9477 closed 3 years ago

R3D9477 commented 3 years ago

Hello. I've got some trouble with qmlsink on i.mx6 SoC. My QML application displayed only one frame, then application was freezing for a while, and then it excepted with message: 0:00:16.338467336 244 0xc7570 ERROR imxv4l2bufferpool v4l2_buffer_pool.c:275:gst_imx_v4l2_buffer_pool_acquire_buffer:<imxv4l2bufferpool0> VIDIOC_DQBUF failed: Timer expired

Here is example of my application: main.qml:

import QtQuick 2.15
import QtQuick.Window 2.15

import org.freedesktop.gstreamer.GLVideoItem 1.0

Window
{
    id: window
    visible: true
    width: 1024
    height: 768
    color: "black"

    GstGLVideoItem
    {
        id: video
        objectName: "videoItem"
        anchors.fill: parent
    }
}

main.cpp:

#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQuickWindow>
#include <QQuickItem>
#include <QRunnable>
#include <gst/gst.h>
#include <iostream>

class SetPlaying : public QRunnable
{
    GstElement* pipeline_;
public:
    SetPlaying(GstElement* pipeline)
    {
        this->pipeline_ = pipeline ? static_cast<GstElement*>(gst_object_ref(pipeline)) : NULL;
    }
    ~SetPlaying()
    {
        if (this->pipeline_)
            gst_object_unref (this->pipeline_);
    }
    void run()
    {
        if (this->pipeline_)
            gst_element_set_state (this->pipeline_, GST_STATE_PLAYING);
    }
};

int main(int argc, char* argv[])
{
  int ret;

  gst_init (&argc, &argv);

  {
    QGuiApplication app(argc, argv);

    GstElement* pipeline = gst_pipeline_new (NULL);

    GstElement* src = gst_element_factory_make("imxv4l2videosrc", NULL);
    GstElement* transform = gst_element_factory_make("imxipuvideotransform", NULL);
    GstElement* glupload = gst_element_factory_make("glupload", NULL);
    GstElement* sink = gst_element_factory_make("qmlglsink", NULL);

    g_assert (src && glupload && sink);
    gst_bin_add_many(GST_BIN (pipeline), src, transform, glupload, sink, NULL);
    gst_element_link_many(src, transform, glupload, sink, NULL);

    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    QQuickWindow* rootObject = static_cast<QQuickWindow*>(engine.rootObjects().first());
    QQuickItem* videoItem = rootObject->findChild<QQuickItem*>("videoItem");

    g_assert (videoItem);
    g_object_set(sink, "widget", videoItem, NULL);

    rootObject->scheduleRenderJob(new SetPlaying{pipeline}, QQuickWindow::BeforeSynchronizingStage);
    ret = app.exec();

    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);
  }

  gst_deinit ();
  return ret;
}

but the next pipelines work fine, for example: gst-launch-1.0 imxv4l2videosrc ! imxipuvideotransform ! imxeglvivsink or gst-launch-1.0 imxv4l2videosrc ! imxipuvideotransform ! glupload ! fakesink etc.

Also, I've tried to play with these lines https://github.com/Freescale/gstreamer-imx/commit/af76b354ff5088fd983790da34c4b3d2574c23df , but I've got the same exception.

Qt 5.15 gstreamer-1.18.5.1 gstreamer-imx 0.13.1 imx-gpu-viv-5.0.11.p8.6-hfp

Does anyone have any ideas? Please, help me. I'm stuck :-( Thanks!

R3D9477 commented 3 years ago

If replace imxipuvideotransform with videoconvert it works, but perfomance is poor. Looks like image conversion work on CPU, not on GPU