Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Video plays on a new Window while launched through gstreamer in Qt6 qml application
Forum Updated to NodeBB v4.3 + New Features

Video plays on a new Window while launched through gstreamer in Qt6 qml application

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
20 Posts 5 Posters 1.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thanush
    wrote on last edited by
    #1

    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 qml

    VideoClass.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
        }
    }
    

    error.jpg
    Thanks in Advance

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Your pipeline does not reference any sink hence it's opening a new window.

      You should check the qmlsink example from gstreamer.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      JoeCFDJ T 2 Replies Last reply
      1
      • SGaistS SGaist

        Hi,

        Your pipeline does not reference any sink hence it's opening a new window.

        You should check the qmlsink example from gstreamer.

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #3

        @SGaist it is qml6glsink for Qt6 while qmlglsink is for Q5

        SGaistS 1 Reply Last reply
        1
        • JoeCFDJ JoeCFD

          @SGaist it is qml6glsink for Qt6 while qmlglsink is for Q5

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @JoeCFD good point. The logic of the example still applies though.

          There should be a new example for Qt 6 written :-)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Your pipeline does not reference any sink hence it's opening a new window.

            You should check the qmlsink example from gstreamer.

            T Offline
            T Offline
            Thanush
            wrote on last edited by
            #5

            Hi @SGaist , I tried to reuse the code in mine and the build was success but while running it was crashing with an error

            Bail out! ERROR:../../main.cpp:35:int main(int, char**): assertion failed: (src && glupload && sink)
            
            jsulmJ 1 Reply Last reply
            0
            • T Thanush

              Hi @SGaist , I tried to reuse the code in mine and the build was success but while running it was crashing with an error

              Bail out! ERROR:../../main.cpp:35:int main(int, char**): assertion failed: (src && glupload && sink)
              
              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Thanush So, did you check what is in line 35 in main.cpp?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              T 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Thanush So, did you check what is in line 35 in main.cpp?

                T Offline
                T Offline
                Thanush
                wrote on last edited by
                #7

                @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);
                
                jsulmJ T 2 Replies Last reply
                0
                • T Thanush

                  @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);
                  
                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @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.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • T Thanush

                    @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);
                    
                    T Offline
                    T Offline
                    Thanush
                    wrote on last edited by
                    #9

                    @Thanush said in Video plays on a new Window while launched through gstreamer in Qt6 qml application:

                    GstElement *sink = gst_element_factory_make ("qmlglsink", NULL);

                    This returns a null pointer, I'm not sure why

                    JoeCFDJ 1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      Bob64
                      wrote on last edited by
                      #10

                      I know nothing about this, but wasn't it pointed out above that it should be "qml6glsink"?

                      1 Reply Last reply
                      3
                      • T Thanush

                        @Thanush said in Video plays on a new Window while launched through gstreamer in Qt6 qml application:

                        GstElement *sink = gst_element_factory_make ("qmlglsink", NULL);

                        This returns a null pointer, I'm not sure why

                        JoeCFDJ Offline
                        JoeCFDJ Offline
                        JoeCFD
                        wrote on last edited by JoeCFD
                        #11

                        @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.

                        T 1 Reply Last reply
                        0
                        • JoeCFDJ JoeCFD

                          @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.

                          T Offline
                          T Offline
                          Thanush
                          wrote on last edited by
                          #12

                          @JoeCFD I am using Ubuntu and the gstreamer version is version 1.20.3. I also tried with qml6glsink and qmlglsink and the result is same

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            Did you install the GStreamer plugin packages ?

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            T 2 Replies Last reply
                            0
                            • SGaistS SGaist

                              Did you install the GStreamer plugin packages ?

                              T Offline
                              T Offline
                              Thanush
                              wrote on last edited by
                              #14

                              @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
                              
                              
                              1 Reply Last reply
                              0
                              • SGaistS SGaist

                                Did you install the GStreamer plugin packages ?

                                T Offline
                                T Offline
                                Thanush
                                wrote on last edited by
                                #15

                                @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.

                                SGaistS 1 Reply Last reply
                                0
                                • T Thanush

                                  @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.

                                  SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  @Thanush It's not a Qt 6 issue, it's a GStreamer issue. I think the version you are using is too old and does not contain the class yet.

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  T 1 Reply Last reply
                                  0
                                  • SGaistS SGaist

                                    @Thanush It's not a Qt 6 issue, it's a GStreamer issue. I think the version you are using is too old and does not contain the class yet.

                                    T Offline
                                    T Offline
                                    Thanush
                                    wrote on last edited by
                                    #17

                                    Hi @SGaist .So that was the problem? Update the Gstreamer to latest version and this issue would be resolved?

                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #18

                                      That would be it, yes.

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      T 1 Reply Last reply
                                      0
                                      • SGaistS SGaist

                                        That would be it, yes.

                                        T Offline
                                        T Offline
                                        Thanush
                                        wrote on last edited by
                                        #19

                                        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..

                                        1 Reply Last reply
                                        0
                                        • SGaistS Offline
                                          SGaistS Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #20

                                          You would have to build the plugin yourself and link against it.

                                          Interested in AI ? www.idiap.ch
                                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved