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. Display Gstreamer video on Android
QtWS25 Last Chance

Display Gstreamer video on Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
gstreamergstreamer videoandroidopengl
36 Posts 4 Posters 21.0k 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.
  • D Offline
    D Offline
    don-prog
    wrote on 2 May 2016, 02:19 last edited by
    #1

    Hi!
    I try to display video on Android using Gstreamer like on other platforms:

            GstElement *pipeline;
            GError *error = NULL;
            pipeline = gst_parse_launch("videotestsrc ! glimagesink", &error);
            if (!pipeline) {
                ui->label->setText("error");
                return;
            }
            if(error != NULL){
                qDebug("GST error: ");
                qDebug(error->message);
            }
            else{
                qDebug("GST without errors");
            }
    
            gst_element_set_state(pipeline, GST_STATE_READY);
    
            GstElement *video_sink = gst_bin_get_by_interface(GST_BIN(pipeline), GST_TYPE_VIDEO_OVERLAY);
            if (!video_sink) {
                qDebug ("Could not retrieve video sink");
                return;
            }
            gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(video_sink), this->ui->playback_widget->winId());
    	//playback_widget - QOpenGLWidget
    
            gst_element_set_state(pipeline, GST_STATE_PLAYING);
    

    But this code doesn't works, after gst_video_overlay_set_window_handle() function I get:
    F libc : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x5e in tid 3154 (gstglcontext)

    Maybe I need to get the pointer to ANativeWindow? But how can I get this with Qt on Android?
    Anyway I need to display video on Android using Gstreamer, so any help will be useful.
    Thanks.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 2 May 2016, 20:45 last edited by
      #2

      Hi and welcome to devnet,

      Did you build Qt's GStreamer backend for Android ?

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

      D 1 Reply Last reply 2 May 2016, 21:34
      0
      • S SGaist
        2 May 2016, 20:45

        Hi and welcome to devnet,

        Did you build Qt's GStreamer backend for Android ?

        D Offline
        D Offline
        don-prog
        wrote on 2 May 2016, 21:34 last edited by
        #3

        @SGaist thanks for the response!
        I downloaded GStreamer for Android from https://gstreamer.freedesktop.org/data/pkg/android/, set INCLUDEPATH and LIBS flags for GStreamer libraries and got some working GStreamer samples with audio. All works fine, except display video.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 2 May 2016, 21:39 last edited by
          #4

          Then you should either try with their QtGstreamer module or try building Qt's GStreamer backend.

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

          D 1 Reply Last reply 2 May 2016, 21:49
          0
          • S SGaist
            2 May 2016, 21:39

            Then you should either try with their QtGstreamer module or try building Qt's GStreamer backend.

            D Offline
            D Offline
            don-prog
            wrote on 2 May 2016, 21:49 last edited by
            #5

            @SGaist are you sure? Because I just get only these issues with display video(audio playback and all other pipelines works fine). If yes, then where can I find how can I do this? And is QtGstreamer(not pure Gstreamer) cross-platform?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 2 May 2016, 22:50 last edited by
              #6

              Displaying a video is not a simple as playing a sound especially on mobile platforms where there are restrictions on the resources available for applications.

              Qt's GStreamer backend implements that part for you.

              QtGstreamer can run on platforms where its dependencies can be built.

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

              D 1 Reply Last reply 2 May 2016, 23:18
              0
              • S SGaist
                2 May 2016, 22:50

                Displaying a video is not a simple as playing a sound especially on mobile platforms where there are restrictions on the resources available for applications.

                Qt's GStreamer backend implements that part for you.

                QtGstreamer can run on platforms where its dependencies can be built.

                D Offline
                D Offline
                don-prog
                wrote on 2 May 2016, 23:18 last edited by
                #7

                @SGaist hm... interesting. I didn't know these details, many thanks! And how can I do this on Android?
                And some clarifying for our mutual understanding: Can I do this on Windows, Linux, OS X, iOS and Android? Because I only heard about QtGstreamer on Linux.
                Regards.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 3 May 2016, 20:18 last edited by
                  #8

                  Do you mean build Qt's GStreamer backend for Android ?

                  You have to check the availability of the module's dependencies for these platform (or build them by hand)

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

                  D 1 Reply Last reply 3 May 2016, 20:31
                  0
                  • S SGaist
                    3 May 2016, 20:18

                    Do you mean build Qt's GStreamer backend for Android ?

                    You have to check the availability of the module's dependencies for these platform (or build them by hand)

                    D Offline
                    D Offline
                    don-prog
                    wrote on 3 May 2016, 20:31 last edited by
                    #9

                    @SGaist ok, and can you share some simple example how can I build Qt's GStreamer backend for Android? Because I even don't know how I can start.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 3 May 2016, 20:45 last edited by
                      #10

                      Sorry, I don't have an example by hand but based on the QtMultimedia sources, the first thing I'd do is get gstreamer for Android and then I'd modify the plugins.pro file and add the gstreamer subdir to the list in the android scope.

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

                      D 1 Reply Last reply 3 May 2016, 20:57
                      0
                      • S SGaist
                        3 May 2016, 20:45

                        Sorry, I don't have an example by hand but based on the QtMultimedia sources, the first thing I'd do is get gstreamer for Android and then I'd modify the plugins.pro file and add the gstreamer subdir to the list in the android scope.

                        D Offline
                        D Offline
                        don-prog
                        wrote on 3 May 2016, 20:57 last edited by
                        #11

                        @SGaist ok, thanks. And what is the difference between QtGstreamer module and Qt's GStreamer backend?

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 3 May 2016, 21:01 last edited by
                          #12

                          The QtGstreamer module is on a lower-level. It essentially provides you a nice Qt API to build your GStreamer pipelines and a set of video sync for QtWidgets and QtQuick.

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

                          D 1 Reply Last reply 3 May 2016, 21:09
                          0
                          • S SGaist
                            3 May 2016, 21:01

                            The QtGstreamer module is on a lower-level. It essentially provides you a nice Qt API to build your GStreamer pipelines and a set of video sync for QtWidgets and QtQuick.

                            D Offline
                            D Offline
                            don-prog
                            wrote on 3 May 2016, 21:09 last edited by
                            #13

                            @SGaist as I understand QtGstreamer will works for my issue too, so what is more preferable? How can I use QtGstreamer? And is it cross-platform? Thanks!

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 3 May 2016, 21:16 last edited by
                              #14

                              It should run on the same platforms as Qt as long as you can satisfy its dependencies.

                              I'd first try to build the backend. It will likely be less work.

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

                              D 1 Reply Last reply 3 May 2016, 21:47
                              0
                              • S SGaist
                                3 May 2016, 21:16

                                It should run on the same platforms as Qt as long as you can satisfy its dependencies.

                                I'd first try to build the backend. It will likely be less work.

                                D Offline
                                D Offline
                                don-prog
                                wrote on 3 May 2016, 21:47 last edited by
                                #15

                                @SGaist understood. Thanks for the explanations. About backend:
                                I need download GStreamer for Android(this I already did, right?), create plugins.pro file in the my project(I don't know even what is it, but I will read) and add GStreamer dir to the list in the android scope(don't heard about this too). Is it all what I need?

                                1 Reply Last reply
                                0
                                • S Offline
                                  S Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on 3 May 2016, 22:05 last edited by
                                  #16

                                  No, you have to build the plugin from the sources and then install them

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

                                  D 1 Reply Last reply 3 May 2016, 22:14
                                  0
                                  • S SGaist
                                    3 May 2016, 22:05

                                    No, you have to build the plugin from the sources and then install them

                                    D Offline
                                    D Offline
                                    don-prog
                                    wrote on 3 May 2016, 22:14 last edited by
                                    #17

                                    @SGaist can you share the link which describes what I need to do? Or some additional reading? I'm sorry but I really don't understand a lot of things. Where I need to set a plugins.pro? What I need to set within it? About which plugin are you said? How and where I need to install it? How connect GStreamer to all these things?

                                    1 Reply Last reply
                                    0
                                    • S Offline
                                      S Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on 4 May 2016, 07:06 last edited by
                                      #18

                                      You don't need to create any file. You have to first get the sources of the QtMultimedia module.

                                      There you'll find the plugins folder with the matching plugins.pro file

                                      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
                                      0
                                      • LuJoRiL Offline
                                        LuJoRiL Offline
                                        LuJoRi
                                        wrote on 4 May 2016, 07:45 last edited by LuJoRi 5 Apr 2016, 09:21
                                        #19

                                        Hi don-prog!

                                        I've had the same issue as you...displaying a GStreamer video on Android within a Qt application!
                                        It was a hard way to find out how to get it alltogether work and it took me a long time! I wasn't able to find really useful hints about this issue.

                                        First I also tried it with QtGStreamer, but I didn't get it work for Android. After trying and trying and trying (...) I decided to look for another way to go. By the way - for Linux the QtGStreamer worked like a charm.

                                        As you can see at this link (https://wiki.qt.io/Qt_5.5.0_Multimedia_Backends) the multimedia backend of Qt uses different multimedia frameworks on different platforms --> GStreamer is only used for Linux and I think this decision wasn't made causeless! I don't think it will be so easy to get the Qt's GStreamer-Backend to work for Android since a Qt application for Android comes with partial other characteristics than a Qt application for Linux. That's based in the differences between the dissimilar windowing-systems of Android and Desktop-Linux.

                                        If you display some patience I'll show you how I did it?

                                        Greetz, Lukas

                                        1 Reply Last reply
                                        0
                                        • S Offline
                                          S Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on 4 May 2016, 10:38 last edited by SGaist 5 Apr 2016, 10:38
                                          #20

                                          Hi and welcome to devnet,

                                          @LuJoRi Indeed it wasn't mad causeless because Qt uses as much as possible native frameworks.

                                          If I understand you correctly you successfully used GStreamer on Android with Qt to do video rendering ?

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

                                          D LuJoRiL 2 Replies Last reply 4 May 2016, 20:19
                                          0

                                          1/36

                                          2 May 2016, 02:19

                                          • Login

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