Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to display RTSP Stream using QT? I already used LibVlc-QT for display, but i didn't get control over stream after using this library. So I don't want to use LibVlC QT.
QtWS25 Last Chance

How to display RTSP Stream using QT? I already used LibVlc-QT for display, but i didn't get control over stream after using this library. So I don't want to use LibVlC QT.

Scheduled Pinned Locked Moved Mobile and Embedded
rtspstreamubuntu 14.04imx6
11 Posts 3 Posters 24.1k Views
  • 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.
  • K Offline
    K Offline
    kuber saini
    wrote on 15 Oct 2015, 07:57 last edited by
    #1

    Hi,
    I want to display RTSP stream using QT. I am using DSS for as a streaming server. Now I want to display that stream on Qt.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tomasz3dk
      wrote on 15 Oct 2015, 09:48 last edited by
      #2

      Hi, and welcome. Maybe gstreamer will be better for your solution.

      1 Reply Last reply
      1
      • K Offline
        K Offline
        kuber saini
        wrote on 15 Oct 2015, 10:23 last edited by
        #3

        Thanks tomasz3dk,
        You mean to replace Qt with GStreamer to display the streaming video?
        or to use GStreamer instead of DSS for streaming?

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tomasz3dk
          wrote on 15 Oct 2015, 11:42 last edited by
          #4

          I mean replace libVLC with gstreamer.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kuber saini
            wrote on 15 Oct 2015, 12:37 last edited by
            #5

            I got sample code to play RTSP stream using Gstreamer. Here is the code:

            #include <gst/gst.h>

            int main(int argc, char *argv[])
            {
            GstElement *pipeline;
            GstBus *bus;
            GstMessage *msg;

            /* Initialize GStreamer */
            gst_init (&argc, &argv);

            /* Build the pipeline */
            pipeline = gst_parse_launch ("playbin2 uri=rtsp://172.19.91.21/channel.sdp", NULL);

            /* Start playing */
            gst_element_set_state (pipeline, GST_STATE_PLAYING);

            /* Wait until error or EOS */
            bus = gst_element_get_bus (pipeline);
            msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

            /* Free resources */
            if (msg != NULL)
            gst_message_unref (msg);
            gst_object_unref (bus);
            gst_element_set_state (pipeline, GST_STATE_NULL);
            gst_object_unref (pipeline);
            return 0;
            }

            But using this code, I can not display my stream data on Qt GUI.
            I have created GUI using Qt and now i want to display this RTSP stream on that Qt's GUI. So I feel this code is not useful to do that.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tomasz3dk
              wrote on 15 Oct 2015, 13:11 last edited by
              #6

              On which platform plugin are you running this code (eglfs, xcb,) ? Also there are Qt bindings for gstreamer, that you can use in your project: Qt gstreamer.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kuber saini
                wrote on 16 Oct 2015, 06:38 last edited by
                #7

                I am using ubuntu trusty image on iMX6 Board (Nitrogen 6 Max). I am trying to build and code using QtGstreamer library. Will post here once I done with it.
                Thanks tomaz3dk.

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  kuber saini
                  wrote on 2 Nov 2015, 07:19 last edited by kuber saini 11 Feb 2015, 08:55
                  #8

                  So finally I am able to display live RTSP Stream on QT's surface(Qt Widgets). Here is the sample code:

                  // Sample code to play rtsp stream on qt widgets
                  int main(int argc, char *argv[])
                  {
                        gst_init (&argc, &argv);
                        QApplication app(argc, argv);
                        app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ()));
                  
                        // prepare the pipeline
                        GstElement *pipeline = gst_parse_launch ("playbin uri=rtsp://172.19.91.21/channel.sdp", NULL);
                  
                        // prepare the ui
                        QWidget window;
                        window.setWindowTitle("MyWidget");
                        window.resize(640, 480);
                        window.show();
                  
                        WId xwinid = window.winId();
                        //this is the call to overlay the gstreamer's output to the Qt Widgets...
                        gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (pipeline), 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();
                  
                        window.hide();
                        gst_element_set_state (pipeline, GST_STATE_NULL);
                        gst_object_unref (pipeline);
                  
                        return ret;
                  }
                  

                  Thanks tomaz3dk.

                  1 Reply Last reply
                  1
                  • T Offline
                    T Offline
                    tomasz3dk
                    wrote on 3 Nov 2015, 09:59 last edited by
                    #9

                    No problem ;) Just for explanation. This code will work only in xcb platfrom and not with eglfs. BTW you missed "s" in my nick it's "tomasz3dk", not "tomaz3dk".

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      kuber saini
                      wrote on 3 Nov 2015, 11:01 last edited by
                      #10

                      oops.. Sorry for the name.
                      Actually I am developing my application for Ubuntu and right now no plan to port on other platform. But If I face any problem I will post here.. :D
                      Thanks tomasz3dk :)

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        Ranjeet Dhumal
                        wrote on 25 Feb 2025, 06:17 last edited by
                        #11

                        kuber saini using activeWindow() to capture frames for RTSP streaming, but when the HDMI cable is removed, no frames are sent.

                        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