Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QmlGlSink BlackScreen on Rtsp Display
Forum Updated to NodeBB v4.3 + New Features

QmlGlSink BlackScreen on Rtsp Display

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.3k Views 1 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.
  • F Offline
    F Offline
    FLavenN
    wrote on last edited by
    #1

    When i try to build & run the example down below i see the videotestsrc in my qml. But i can not do the same for a rtsp stream. Only thing that i get is a black screen ? Any help would be appreciated.

    Here is the example : https://github.com/GStreamer/gst-plugins-good/tree/1.18/tests/examples/qt/qmlsink

    And here is a part of my code :

        GstElement *pipeline = gst_pipeline_new(NULL);
        GstElement *src = gst_element_factory_make("rtspsrc",NULL);
        GstElement *rtph264depay = gst_element_factory_make("rtph264depay",NULL);
        GstElement *h264parse = gst_element_factory_make("h264parse",NULL);
        //GstElement *encoder = gst_element_factory_make("x264enc",NULL);
        GstElement *decoder = gst_element_factory_make("avdec_h264",NULL);
        GstElement *glupload = gst_element_factory_make("glupload",NULL);
        GstElement *glcolorconvert = gst_element_factory_make("glcolorconvert",NULL);
        GstElement *qmlglsink = gst_element_factory_make("qmlglsink",NULL);
    
        g_assert(src  && rtph264depay && h264parse && decoder && glupload &&  glcolorconvert && qmlglsink);
    
        g_object_set(G_OBJECT(src), "location", "rtsp://localhost:9300/" , NULL);
        gst_bin_add_many(GST_BIN(pipeline), src, rtph264depay,h264parse,decoder,glupload,  glcolorconvert , qmlglsink , NULL );
        gst_element_link_many(src,  rtph264depay,h264parse,decoder,glupload,  glcolorconvert , qmlglsink , 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(qmlglsink , "widget", videoItem, NULL);
    
        rootObject->scheduleRenderJob (new SetPlaying (pipeline),
                                       QQuickWindow::BeforeSynchronizingStage);
    
        ret = app.exec();
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Beside the QML sink, are you sure the rest of the pipeline is correct ?

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

      F 1 Reply Last reply
      0
      • F Offline
        F Offline
        FLavenN
        wrote on last edited by
        #3

        Yes i guess so i've tried other pipelines that works correctly. But what i've noticed when i use decodebin i get black screen.

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          Beside the QML sink, are you sure the rest of the pipeline is correct ?

          F Offline
          F Offline
          FLavenN
          wrote on last edited by
          #4

          @SGaist When i use some pipeline like this :

          gst-launch-1.0 filesrc location=C:/Users/X/Desktop/Stabil.mp4 ! decodebin ! glupload ! glcolorconvert ! glimagesink

          It works but when i convert this to my code i guess the decodebin what makes it looks like a black screen.

          And here is my code for a pipeline like this :

              GstElement *pipeline = gst_pipeline_new (NULL);
              GstElement *src = gst_element_factory_make ("filesrc", NULL);
              GstElement *decoder = gst_element_factory_make("decodebin",NULL);
              GstElement *glupload = gst_element_factory_make ("glupload", NULL);
              GstElement *glcolorconvert = gst_element_factory_make("glcolorconvert",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_object_set(G_OBJECT(src), "location", "C:/Users/X/Desktop/Stabil.mp4" , NULL);
              g_assert (src &&  decoder &&  glupload && glcolorconvert &&  sink);
          
              gst_bin_add_many (GST_BIN (pipeline), src, decoder , glupload,  glcolorconvert , sink, NULL);
              gst_element_link_pads(src, "src", decoder, "sink");
              gst_element_link_many (src,  decoder , glupload, glcolorconvert , 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();
          
          1 Reply Last reply
          0
          • N Offline
            N Offline
            nishithaa
            wrote on last edited by
            #5

            Please verify which is the decoder element used by decodebin. If you had installed vaapi plugins, then decodebin takes that element by default , and not avdec_h264. vaapi decoder output cannot be directly linked to qmlsink

            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