Video plays on a new Window while launched through gstreamer in Qt6 qml application
-
Hi,
I used the gstreamer cmd for playing a video in qt. The video is generated on a new window. How do I generate the video inside of the mainwindow on click of a button without using multimedia concepts in qmlVideoClass.cpp VideoClass::VideoClass(QObject *parent, int argc, char *argv[]) : QObject{parent} { gst_init(&argc,&argv); } void VideoClass::pipelineDescription(QString path) { pipeline = gst_parse_launch("playbin uri=file://" + path.toUtf8(), 0); gst_element_set_state(pipeline, GST_STATE_PLAYING); } main.cpp #include <QGuiApplication> #include <QQmlApplicationEngine> #include "videoclass.h" int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); qmlRegisterType<VideoClass>("com.video",1,0,"Gstreamer"); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/VideoTest/main.qml")); QObject::connect( &engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec(); } main.qml import QtQuick import QtQuick.Controls 2.15 import com.video 1.0 Window { width: 640 height: 480 visible: true title: qsTr("Hello World") Button{ id: mybtn width: 150 height: 50 anchors.bottom: parent.bottom text: "Generate" MouseArea{ anchors.fill: parent onClicked:{ gst.pipelineDescription("/home/thanush/big_buck_bunny_720p_1mb.mp4") } } } Gstreamer{ id: gst } }
Thanks in Advance -
Hi,
Your pipeline does not reference any sink hence it's opening a new window.
You should check the qmlsink example from gstreamer.
-
@jsulm , Apologies..
GstElement *pipeline = gst_pipeline_new (NULL); GstElement *src = gst_element_factory_make ("videotestsrc", NULL); GstElement *glupload = gst_element_factory_make ("glupload", NULL); GstElement *sink = gst_element_factory_make ("qmlglsink", NULL); **g_assert (src && glupload && sink);**//This line caused the error gst_bin_add_many (GST_BIN (pipeline), src, glupload, sink, NULL); gst_element_link_many (src, glupload, sink, NULL);
-
@Thanush said in Video plays on a new Window while launched through gstreamer in Qt6 qml application:
g_assert (src && glupload && sink);
So, at least one of these 3 failed. You can check which one.
-
@Thanush said in Video plays on a new Window while launched through gstreamer in Qt6 qml application:
qmlglsink
What is your OS? What is your gstreamer version? In order to use qml6glsink(or qmlglsink), you need to install GStreamer Good Plug-in. It is likely that gstreamer good plug-in does not include qml6glsink because it needs qt 6 to be built. In this case, you have to build gstreamer with Qt6 by yourself. The old gstreamer versions do not have qml6glsink.
-
Did you install the GStreamer plugin packages ?
-
@SGaist These are the gstreamer packages present in my ubuntu
ii gir1.2-gstreamer-1.0:amd64 1.20.3-0ubuntu1 amd64 GObject introspection data for the GStreamer library ii gstreamer1.0-alsa:amd64 1.20.1-1ubuntu0.1 amd64 GStreamer plugin for ALSA ii gstreamer1.0-clutter-3.0:amd64 3.0.27-2ubuntu1 amd64 Clutter PLugin for GStreamer 1.0 ii gstreamer1.0-gl:amd64 1.20.1-1ubuntu0.1 amd64 GStreamer plugins for GL ii gstreamer1.0-gtk3:amd64 1.20.3-0ubuntu1.1 amd64 GStreamer plugin for GTK+3 ii gstreamer1.0-libav:amd64 1.20.3-0ubuntu1 amd64 ffmpeg plugin for GStreamer ii gstreamer1.0-packagekit 1.2.5-2ubuntu2 amd64 GStreamer plugin to install codecs using PackageKit ii gstreamer1.0-pipewire:amd64 0.3.48-1ubuntu3 amd64 GStreamer 1.0 plugin for the PipeWire multimedia server ii gstreamer1.0-plugins-bad:amd64 1.20.3-0ubuntu1.1 amd64 GStreamer plugins from the "bad" set ii gstreamer1.0-plugins-base:amd64 1.20.1-1ubuntu0.1 amd64 GStreamer plugins from the "base" set ii gstreamer1.0-plugins-base-apps 1.20.1-1ubuntu0.1 amd64 GStreamer helper programs from the "base" set ii gstreamer1.0-plugins-good:amd64 1.20.3-0ubuntu1.1 amd64 GStreamer plugins from the "good" set ii gstreamer1.0-plugins-ugly:amd64 1.20.1-1 amd64 GStreamer plugins from the "ugly" set ii gstreamer1.0-pulseaudio:amd64 1.20.3-0ubuntu1.1 amd64 GStreamer plugin for PulseAudio (transitional package) ii gstreamer1.0-tools 1.20.3-0ubuntu1 amd64 Tools for use with GStreamer ii gstreamer1.0-x:amd64 1.20.1-1ubuntu0.1 amd64 GStreamer plugins for X11 and Pango ii libgstreamer-gl1.0-0:amd64 1.20.1-1ubuntu0.1 amd64 GStreamer GL libraries ii libgstreamer-plugins-bad1.0-0:amd64 1.20.3-0ubuntu1.1 amd64 GStreamer libraries from the "bad" set ii libgstreamer-plugins-base1.0-0:amd64 1.20.1-1ubuntu0.1 amd64 GStreamer libraries from the "base" set ii libgstreamer-plugins-base1.0-dev:amd64 1.20.1-1ubuntu0.1 amd64 GStreamer development files for libraries from the "base" set ii libgstreamer-plugins-good1.0-0:amd64 1.20.3-0ubuntu1.1 amd64 GStreamer development files for libraries from the "good" set ii libgstreamer-plugins-good1.0-dev 1.20.3-0ubuntu1.1 amd64 GStreamer development files for libraries from the "good" set ii libgstreamer1.0-0:amd64 1.20.3-0ubuntu1 amd64 Core GStreamer libraries and elements ii libgstreamer1.0-dev:amd64 1.20.3-0ubuntu1 amd64 GStreamer core development files
-
@SGaist Hi! Does qmlglsink/qml6glsink support in qt6.7? Because I am getting a qml error
QQmlApplicationEngine failed to load component qrc:/untitled8/main.qml:4:1: module "org.freedesktop.gstreamer.GstGLQt6VideoItem" is not installed
Once I comment out this line in main.qml, the application is running but no video is displaying.
-
That would be it, yes.
-
Hi @SGaist, I see that the gstreamer version contains the qml6glsink, but after downloading from the https://gstreamer.freedesktop.org/src/gstreamer/ .... but i am not sure how it needs to be configured against the old version of gstreamer present in ubuntu..
-
You would have to build the plugin yourself and link against it.