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. QML. Display Gstreamer video

QML. Display Gstreamer video

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmlgstreamergstreamer videogstreamer1.0
4 Posts 2 Posters 5.7k 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.
  • don-progD Offline
    don-progD Offline
    don-prog
    wrote on last edited by don-prog
    #1

    I try to use Gstreamer(not QtGstreamer or QtMultimedia) in QML(Qt Quick Controls Application):

    QQmlEngine engine;
       QQmlComponent component(&engine,
               QUrl(QStringLiteral("qrc:/main.qml")));
       QObject *object = component.create();
    
       QWidget *rect = (QWidget*) object->findChild<QObject*>("rectangle1");
    
       gst_init(NULL, NULL);
    
       GstElement *pipeline;
       pipeline = gst_element_factory_make("playbin", "player");
    
       g_object_set (G_OBJECT (pipeline), "uri", "file:///home/user/Downloads/test.mp4", NULL);
    
       gst_element_set_state(pipeline, GST_STATE_NULL);
       gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(pipeline), rect->winId());
       gst_element_set_state(pipeline, GST_STATE_PLAYING);
    

    But my application crashes after start. This code works fine for Qt Widgets, but problem occurs only with QML.
    So how can I display video in QML item via pure Gstreamer(not QtGstreamer or QtMultimedia)?
    P.S. Of course without backend compiling or something like this. I think I just can use right QML item or Widget.
    P.S.S I also heard about QDeclarativeItem, can I use it for this purposes? And how?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      Hi!

      my application crashes after start.

      Do you know why it crashes?

      This code works fine for Qt Widgets, but problem occurs only with QML.

      Qt Quick uses OpenGL and multithreading, Widgets don't. Could be the reason for crashing,

      So how can I display video in QML item via pure Gstreamer(not QtGstreamer or QtMultimedia)?

      Why don't you want to use Qt Multimedia?

      I think I just can use right QML item or Widget.

      The right Qt Quick item for this is the "Video" item from Qt Multimedia. You can't embed Widgets in a Qt Quick scene.

      I also heard about QDeclarativeItem, can I use it for this purposes?

      No, QDeclarativeItem is obsolete.

      don-progD 1 Reply Last reply
      0
      • ? A Former User

        Hi!

        my application crashes after start.

        Do you know why it crashes?

        This code works fine for Qt Widgets, but problem occurs only with QML.

        Qt Quick uses OpenGL and multithreading, Widgets don't. Could be the reason for crashing,

        So how can I display video in QML item via pure Gstreamer(not QtGstreamer or QtMultimedia)?

        Why don't you want to use Qt Multimedia?

        I think I just can use right QML item or Widget.

        The right Qt Quick item for this is the "Video" item from Qt Multimedia. You can't embed Widgets in a Qt Quick scene.

        I also heard about QDeclarativeItem, can I use it for this purposes?

        No, QDeclarativeItem is obsolete.

        don-progD Offline
        don-progD Offline
        don-prog
        wrote on last edited by
        #3

        @Wieland
        Thanks for the response!

        @Wieland said:

        Why don't you want to use Qt Multimedia?

        I don't want to use QtMultimedia because I will use GStreamer not only for video playback but and for some other pipelines(e.g. rtsp and rtp).

        The right Qt Quick item for this is the "Video" item from Qt Multimedia. You can't embed Widgets in a Qt Quick scene.

        Ok, so it is possible somehow to display GStreamer video in QML, right? And how can I use "Video" item for displaying GStreamer video? Am I need to still use gst_video_overlay_set_window_handle() function?

        No, QDeclarativeItem is obsolete.

        And what about QQuickItem and QWidget::createWindowContainer()?
        Regards.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @don-prog said:

          And what about QQuickItem

          You can subclass QQuickItem to create a custom item that you can then use in a Qt Quick scene. In this subclass you can use gstreamer to render a video. So, yes, you can use QQuickItem here. Simply speaking, this is what the Qt Quick Video Item does, too. But please don't ask me how to use gstreamer directly because I have no idea :-)

          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