QML. Display Gstreamer video
-
I try to use Gstreamer(not QtGstreamer or QtMultimedia) in QML(Qt Quick Controls Application):
QQmlEngine engine; QQmlComponent component(&engine, QUrl(QStringLiteral("qrc:/main.qml"))); QObject *object = component.create(); QWidget *rect = (QWidget*) object->findChild<QObject*>("rectangle1"); gst_init(NULL, NULL); GstElement *pipeline; pipeline = gst_element_factory_make("playbin", "player"); g_object_set (G_OBJECT (pipeline), "uri", "file:///home/user/Downloads/test.mp4", NULL); gst_element_set_state(pipeline, GST_STATE_NULL); gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(pipeline), rect->winId()); gst_element_set_state(pipeline, GST_STATE_PLAYING);
But my application crashes after start. This code works fine for Qt Widgets, but problem occurs only with QML.
So how can I display video in QML item via pure Gstreamer(not QtGstreamer or QtMultimedia)?
P.S. Of course without backend compiling or something like this. I think I just can use right QML item or Widget.
P.S.S I also heard about QDeclarativeItem, can I use it for this purposes? And how? -
Hi!
my application crashes after start.
Do you know why it crashes?
This code works fine for Qt Widgets, but problem occurs only with QML.
Qt Quick uses OpenGL and multithreading, Widgets don't. Could be the reason for crashing,
So how can I display video in QML item via pure Gstreamer(not QtGstreamer or QtMultimedia)?
Why don't you want to use Qt Multimedia?
I think I just can use right QML item or Widget.
The right Qt Quick item for this is the "Video" item from Qt Multimedia. You can't embed Widgets in a Qt Quick scene.
I also heard about QDeclarativeItem, can I use it for this purposes?
No, QDeclarativeItem is obsolete.
-
@Wieland
Thanks for the response!@Wieland said:
Why don't you want to use Qt Multimedia?
I don't want to use QtMultimedia because I will use GStreamer not only for video playback but and for some other pipelines(e.g. rtsp and rtp).
The right Qt Quick item for this is the "Video" item from Qt Multimedia. You can't embed Widgets in a Qt Quick scene.
Ok, so it is possible somehow to display GStreamer video in QML, right? And how can I use "Video" item for displaying GStreamer video? Am I need to still use gst_video_overlay_set_window_handle() function?
No, QDeclarativeItem is obsolete.
And what about QQuickItem and QWidget::createWindowContainer()?
Regards. -
@don-prog said:
And what about QQuickItem
You can subclass QQuickItem to create a custom item that you can then use in a Qt Quick scene. In this subclass you can use gstreamer to render a video. So, yes, you can use QQuickItem here. Simply speaking, this is what the Qt Quick Video Item does, too. But please don't ask me how to use gstreamer directly because I have no idea :-)