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. Watching GStreamer RTSP stream in QT6 Widget
Forum Updated to NodeBB v4.3 + New Features

Watching GStreamer RTSP stream in QT6 Widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 377 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.
  • M Offline
    M Offline
    MrHandSOme
    wrote on last edited by
    #1

    I want to watch RTSP Stream in a widget in QT6, but although I specify it at the bottom of the code, it opens in a separate window called "Direct3D11 renderer", not on that qt app widget. If I delete all the elements in between, such as queue videoconvert, it works as I want, but this time there is a lot of delay.

        gst_init(nullptr, nullptr);
        
        GstElement *pipeline = gst_pipeline_new("video-pipeline");
        GstElement *rtspsrc = gst_element_factory_make("rtspsrc", "source");
        GstElement *queue = gst_element_factory_make("queue", "queue");
        GstElement *rtph264depay = gst_element_factory_make("rtph264depay", "depay");
        GstElement *h264parse = gst_element_factory_make("h264parse", "parse");
        GstElement *avdec_h264 = gst_element_factory_make("avdec_h264", "decoder");
        GstElement *videoconvert = gst_element_factory_make("videoconvert", "converter");
        GstElement *videoscale = gst_element_factory_make("videoscale", "scaler");
        GstElement *sink = gst_element_factory_make("autovideosink", "autovideosink");
    
        CHECK_ELEMENT(pipeline, "Pipeline");
        CHECK_ELEMENT(rtspsrc, "RTSP Source");
        CHECK_ELEMENT(queue, "Queue");
        CHECK_ELEMENT(rtph264depay, "RTP H264 Depayloader");
        CHECK_ELEMENT(h264parse, "H264 Parser");
        CHECK_ELEMENT(avdec_h264, "H264 Decoder");
        CHECK_ELEMENT(videoconvert, "Video Converter");
        CHECK_ELEMENT(videoscale, "Video Scaler");
        CHECK_ELEMENT(sink, "Video Sink");
    
        if (!pipeline || !rtspsrc || !queue || !rtph264depay || !h264parse || !avdec_h264 || !videoconvert || !videoscale || !sink) {
            return;
        }
    
        gst_bin_add_many(GST_BIN(pipeline), rtspsrc, queue, rtph264depay, h264parse, avdec_h264, videoconvert, videoscale, sink, nullptr);
    
        if (!gst_element_link_many(queue, rtph264depay, h264parse, avdec_h264, videoconvert, videoscale, sink, nullptr)) {
            gst_object_unref(pipeline);
            return;
        }
    
        g_object_set(G_OBJECT(rtspsrc), "location", "rtsp://127.0.0.1:8554/", nullptr);
        g_object_set(G_OBJECT(rtspsrc), "latency", 100, nullptr);
    
        g_signal_connect(rtspsrc, "pad-added", G_CALLBACK(+[](GstElement *src, GstPad *new_pad, gpointer data) {
                             GstElement *queue = GST_ELEMENT(data);
                             GstPad *sink_pad = gst_element_get_static_pad(queue, "sink");
                             if (gst_pad_is_linked(sink_pad)) {
                                 g_object_unref(sink_pad);
                                 return;
                             }
                             gst_pad_link(new_pad, sink_pad);
                             g_object_unref(sink_pad);
                         }), queue);
    
        WId windowId = ui->widgetCamera->winId();
        GstVideoOverlay *overlay = GST_VIDEO_OVERLAY(sink);
        gst_video_overlay_set_window_handle(overlay, static_cast<guintptr>(windowId));
    
        gst_element_set_state(pipeline, GST_STATE_PLAYING);
    

    I want to see how to play RTSP Stream on qt widget.

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #2

      You are using autovideosink. In order to display RTSP streaming in Qt widget or qml layout, you need to replace autovideosink with qml or widget sink.
      QML sink example is here.
      https://github.com/GStreamer/gst-plugins-good/tree/master/tests/examples/qt

      Note that Qt sinks are created and maintained by gstreamer developers, not by Qt company. If you have any issue with Qt sinks, ask gstreamer guys.

      1 Reply Last reply
      2

      • Login

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