Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Qt and gstreamer
Qt 6.11 is out! See what's new in the release blog

Qt and gstreamer

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
18 Posts 5 Posters 17.0k 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.
  • SGaistS SGaist

    Hi,

    What Linux distribution are you running ?
    What Desktop Environment are you using ?
    What window manager are you using ?

    S Offline
    S Offline
    stephane78 0
    wrote on last edited by stephane78 0
    #3

    @SGaist Hi, I was (at home) on my debian 9 with kde5 plasma but I should try too on centOs (because the target is RHEL).I can display my video with gst-launch but not with my program

    raven-worxR 1 Reply Last reply
    0
    • S stephane78 0

      @SGaist Hi, I was (at home) on my debian 9 with kde5 plasma but I should try too on centOs (because the target is RHEL).I can display my video with gst-launch but not with my program

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #4

      @stephane78-0
      since you are using gstreamer-1.0, did you also compile Qt with gstreamer-1.0 support? AFAIK it uses gstreamer-0.1 by default

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      S 1 Reply Last reply
      1
      • raven-worxR raven-worx

        @stephane78-0
        since you are using gstreamer-1.0, did you also compile Qt with gstreamer-1.0 support? AFAIK it uses gstreamer-0.1 by default

        S Offline
        S Offline
        stephane78 0
        wrote on last edited by stephane78 0
        #5

        @raven-worx Hi thank you,no I didn't compile Qt with gstreamer 1.0 support but do you think I need this ? because I use only a QWidget and the winId handle of the QWidget , here is my code :```

        #include <glib.h>
        #include <gst/gst.h>
        #include <gst/video/videooverlay.h>

        #include <QApplication>
        #include <QTimer>
        #include <QWidget>

        int main(int argc, char *argv[])
        {
        if (!g_thread_supported ())
        g_thread_init (NULL);

        gst_init (&argc, &argv);
        QApplication app(argc, argv);
        //MainWindow w;
        QWidget w;
        w.resize(640,480);

        app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ()));

        // prepare the pipeline

        GstElement *pipeline = gst_pipeline_new ("xvoverlay");
        GstElement *videosrc = gst_element_factory_make ("filesrc","videosrc");
        GstElement *videoscale=gst_element_factory_make("videoscale",NULL);
        GstElement *capsfilter=gst_element_factory_make("capsfilter",NULL);
        GstElement *sink = gst_element_factory_make ("xvimagesink", NULL);
        GstElement *decodebin = gst_element_factory_make("decodebin", NULL);

        //g_object_set (G_OBJECT(playbin),"uri","file:///home/user/Downloads/thesimpsonstrailer.mp4");
        g_object_set (G_OBJECT (videosrc), "location", "/home/user/Downloads/small.mp4", NULL);
        GstCaps *caps = gst_caps_new_simple ("video/x-raw",
        "format", G_TYPE_STRING, "RGB",
        "framerate", GST_TYPE_FRACTION, 25, 1,
        "width", G_TYPE_INT, 640,
        "height", G_TYPE_INT, 480,NULL);

        g_object_set(G_OBJECT(capsfilter), "caps", caps, NULL);
        gst_caps_unref (caps);
        gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, sink, NULL);
        gst_element_link_many(videosrc, decodebin, NULL);
        gst_element_link_many(decodebin, sink, NULL);

        // prepare the ui

        w.show();
        

        gst_element_set_state(sink, GST_STATE_READY);
        WId xwinid =w.winId();
        gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), xwinid);

        // run the pipeline

        GstStateChangeReturn sret = gst_element_set_state (pipeline,
        GST_STATE_PLAYING);
        if (sret == GST_STATE_CHANGE_FAILURE)
        {
        gst_element_set_state (pipeline, GST_STATE_NULL);
        gst_object_unref (pipeline);
        // Exit application
        QTimer::singleShot(0, QApplication::activeWindow(), SLOT(quit()));
        }

        int ret = app.exec();

        w.hide();

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

        return ret;
        }

        raven-worxR 1 Reply Last reply
        0
        • S stephane78 0

          @raven-worx Hi thank you,no I didn't compile Qt with gstreamer 1.0 support but do you think I need this ? because I use only a QWidget and the winId handle of the QWidget , here is my code :```

          #include <glib.h>
          #include <gst/gst.h>
          #include <gst/video/videooverlay.h>

          #include <QApplication>
          #include <QTimer>
          #include <QWidget>

          int main(int argc, char *argv[])
          {
          if (!g_thread_supported ())
          g_thread_init (NULL);

          gst_init (&argc, &argv);
          QApplication app(argc, argv);
          //MainWindow w;
          QWidget w;
          w.resize(640,480);

          app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ()));

          // prepare the pipeline

          GstElement *pipeline = gst_pipeline_new ("xvoverlay");
          GstElement *videosrc = gst_element_factory_make ("filesrc","videosrc");
          GstElement *videoscale=gst_element_factory_make("videoscale",NULL);
          GstElement *capsfilter=gst_element_factory_make("capsfilter",NULL);
          GstElement *sink = gst_element_factory_make ("xvimagesink", NULL);
          GstElement *decodebin = gst_element_factory_make("decodebin", NULL);

          //g_object_set (G_OBJECT(playbin),"uri","file:///home/user/Downloads/thesimpsonstrailer.mp4");
          g_object_set (G_OBJECT (videosrc), "location", "/home/user/Downloads/small.mp4", NULL);
          GstCaps *caps = gst_caps_new_simple ("video/x-raw",
          "format", G_TYPE_STRING, "RGB",
          "framerate", GST_TYPE_FRACTION, 25, 1,
          "width", G_TYPE_INT, 640,
          "height", G_TYPE_INT, 480,NULL);

          g_object_set(G_OBJECT(capsfilter), "caps", caps, NULL);
          gst_caps_unref (caps);
          gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, sink, NULL);
          gst_element_link_many(videosrc, decodebin, NULL);
          gst_element_link_many(decodebin, sink, NULL);

          // prepare the ui

          w.show();
          

          gst_element_set_state(sink, GST_STATE_READY);
          WId xwinid =w.winId();
          gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), xwinid);

          // run the pipeline

          GstStateChangeReturn sret = gst_element_set_state (pipeline,
          GST_STATE_PLAYING);
          if (sret == GST_STATE_CHANGE_FAILURE)
          {
          gst_element_set_state (pipeline, GST_STATE_NULL);
          gst_object_unref (pipeline);
          // Exit application
          QTimer::singleShot(0, QApplication::activeWindow(), SLOT(quit()));
          }

          int ret = app.exec();

          w.hide();

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

          return ret;
          }

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #6

          @stephane78-0
          oh sry...i thought you are talking about the QtMultimedia module

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          S 1 Reply Last reply
          0
          • raven-worxR raven-worx

            @stephane78-0
            oh sry...i thought you are talking about the QtMultimedia module

            S Offline
            S Offline
            stephane78 0
            wrote on last edited by
            #7

            @raven-worx Hi ,you have perhaps a good idea I will try to compile Qt with gstreamer 1.0 support and I come again back

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

              Did you check the winID value ?

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

              S 1 Reply Last reply
              1
              • SGaistS SGaist

                Did you check the winID value ?

                S Offline
                S Offline
                stephane78 0
                wrote on last edited by stephane78 0
                #9

                @SGaist Hi,yes xwinId=228589573

                S 1 Reply Last reply
                0
                • S stephane78 0

                  @SGaist Hi,yes xwinId=228589573

                  S Offline
                  S Offline
                  stephane78 0
                  wrote on last edited by
                  #10

                  Hi, I have tryed another method with the plugin qmlsink s owith qml but I have a black screen, my code comes from an exemple of the plugin good on github:

                  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 ("videotestsrc", NULL);
                      GstElement *src = gst_element_factory_make ("filesrc","videosrc");
                      GstElement *glupload = gst_element_factory_make ("glupload", NULL);
                      GstElement *decodebin = gst_element_factory_make("decodebin", NULL);
                      /* the plugin must be loaded before loading the qml file to register the
                       * GstGLVideoItem qml item */
                      GstElement *sink = gst_element_factory_make ("qmlglsink", NULL);
                  
                      g_assert (src && glupload && sink);
                      g_object_set (G_OBJECT (src), "location", "/home/user/Downloads/small.mp4", NULL);
                      gst_bin_add_many (GST_BIN (pipeline), src, decodebin, glupload, sink, NULL);
                      gst_element_link_many (src, decodebin, glupload, sink, NULL);
                  
                      QQmlApplicationEngine engine;
                      engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
                  
                      QQuickItem *videoItem;
                      QQuickWindow *rootObject;
                  
                      /* find and set the videoItem on the sink */
                      rootObject = static_cast<QQuickWindow *> (engine.rootObjects().first());
                      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;
                  

                  so there is perhaps a problem with my debian 9 or it lacks a library

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

                    Do you get any error message on the console ?

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

                    S 1 Reply Last reply
                    1
                    • SGaistS SGaist

                      Do you get any error message on the console ?

                      S Offline
                      S Offline
                      stephane78 0
                      wrote on last edited by
                      #12

                      @SGaist No there isn't any error message in the console

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

                        Does it work if you follow GStreamer's Qt example ?

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

                        S 1 Reply Last reply
                        1
                        • SGaistS SGaist

                          Does it work if you follow GStreamer's Qt example ?

                          S Offline
                          S Offline
                          stephane78 0
                          wrote on last edited by
                          #14

                          @SGaist I will try it,because I have modified it to have as source my video.so I will try the example not modified and come here again.

                          S 1 Reply Last reply
                          0
                          • S stephane78 0

                            @SGaist I will try it,because I have modified it to have as source my video.so I will try the example not modified and come here again.

                            S Offline
                            S Offline
                            stephane78 0
                            wrote on last edited by stephane78 0
                            #15

                            @SGaist the example without my modifications runs well.so there is something with my filesrc.but I can play my video with gstlaunch and decodebin and xvimagesink.

                            SGaistS 1 Reply Last reply
                            0
                            • S stephane78 0

                              @SGaist the example without my modifications runs well.so there is something with my filesrc.but I can play my video with gstlaunch and decodebin and xvimagesink.

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

                              Then I would gradually modify the example until it does play the file you are trying to play with your code.

                              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
                              2
                              • PeTroVicP Offline
                                PeTroVicP Offline
                                PeTroVic
                                wrote on last edited by
                                #17

                                Hey @SGaist and @stephane78-0 ,
                                Did anyone managed to run that example with "filesrc" instead of "videotestsrc" ?

                                This example works for me, but it uses "videotestsrc" as Source, but I would like to use "filesrc".
                                Because, I want to be able to use a custom video.

                                I'm guessing that I need help with GStreamer, and not QT necessarily. But it's worth taking a shot.

                                1 Reply Last reply
                                0
                                • R Offline
                                  R Offline
                                  RajReddy
                                  wrote on last edited by
                                  #18

                                  you can try:

                                      MediaPlayer{
                                          id: playVideo
                                          source: "gst-pipeline: filesrc location=/home/root/skim-debris.mp4 ! qtdemux ! avdec_h264 ! qtvideosink"
                                          autoLoad: true
                                          autoPlay: true
                                          playbackRate: 1.0
                                          loops: 10
                                      }
                                  
                                      VideoOutput {
                                          anchors.fill: parent
                                          source: playVideo
                                      }
                                  
                                  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