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. Analog cameras, qt and gstreamer
Forum Updated to NodeBB v4.3 + New Features

Analog cameras, qt and gstreamer

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
11 Posts 4 Posters 5.2k Views 4 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.
  • N Offline
    N Offline
    naggety
    wrote on last edited by naggety
    #1

    I'm trying to display video recorded from some analog cameras (PAL video). They're controled by a v4l2 driver which produces raw video buffers (NV12 format). I want to display it using QML + QT Quick. My system is a custom linux built with buildroot, for a custom board with an ARM processor.

    I've tried a simple program and also declarative-camera, but they're not working. At first, I got this output:

    (app-test:221): GStreamer-WARNING **: Name 'video-encodebin' is not unique in bin 'camerabin', not adding
    
    (app-test:221): GStreamer-WARNING **: Name 'videobin-filesink' is not unique in bin 'camerabin', not adding
    
    (app-test:221): GStreamer-WARNING **: Name 'image-encodebin' is not unique in bin 'camerabin', not adding
    
    (app-test:221): GStreamer-WARNING **: Name 'imagebin-filesink' is not unique in bin 'camerabin', not adding
    
    (app-test:221): GStreamer-WARNING **: Name 'viewfinderbin-queue' is not unique in bin 'camerabin', not adding
    CameraBin error: "Your GStreamer installation is missing a plug-in."
    

    Running gst-launch-1.0 camerabin it complains about lacking ogg muxer. Then, I enable ogg from buildroot, launch the program again and I get:

    (app-test:241): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
    CameraBin error: "Device '/dev/video1' cannot capture in the specified format"
    CameraBin error: "Internal data stream error."
    

    But I wonder if this kind of cameras are even supported by QML Camera item, or if only digital cameras are.

    I also need to have a bit more control over the cameras. For example, this V4L2 driver have multiple inputs you can choose from, and I need to choose it. Can I do it?

    I also need to ensure a good performance avoiding overhead because video conversions, so I'd rather to use the raw format I get from the driver if possible. I've read somewhere that VideoOutput supports some raw formats, but I don't know which ones and how to use it. Does it support NV12? How can I make to get the NV12 video stream from the driver and show it in a VideoOutput element?

    I suspect that QT Multimedia doesn't allow me to do all this. So, do I have to use Gstreamer directly? And how I should use it? I've seen that there exists QTGstreamer but it seems to be deprecated, can I still use it to output my video to a QML surface? Or do I have to use the new qmlglsink? In that case, how do I have to use it? I can't find any example.

    Please consider that I'm just learning all about these things, so I would like to know the less complex solution, but well supported to be uses with QT Quick.

    Thanks in advance

    1 Reply Last reply
    0
    • mrdebugM Offline
      mrdebugM Offline
      mrdebug
      wrote on last edited by
      #2

      Hi. In order to manage v4l video cameras I'm using OpenCV, to manage rtsp video cameras and movies (to read and to create) I'm using ffmpeg.
      What do you have to do? My approach is more complicated than use gstreamer but if it is very great and works everywhere.

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      1 Reply Last reply
      1
      • N Offline
        N Offline
        naggety
        wrote on last edited by
        #3

        I'm so sorry, I was testing some possible workarounds and I forgot this thread.

        What I've finally done is using Gstreamer (alone, not QTGstreamer) with qmlglsink element. In my case, I needed some fixes in Gstreamer that are going to be included in version 1.15 but it's working.

        About Camera QML element I still don't know if it's supposed to work with analog cameras. I think yes, but I haven't it working yet because I think my driver is a bit buggy, I'll try to fix it.

        I have tested using the QML example from Gstreamer, but modifying the pipeline to use my cameras instead of videotestsrc.

        This is the original example: https://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/tests/examples/qt/qmlsink?id=b03df1abf828514b0966db058388bf974ed0cf4f

        And this is the pipeline I've used:

            // Pipeline object
            GstElement *pipeline = gst_pipeline_new (NULL);
        
            // v4l2 src, selecting device /dev/video1
            GstElement *src = gst_element_factory_make("v4l2src", NULL);
            g_object_set (src, "device", "/dev/video1", NULL);
        
            // caps selection: format, width, height...
            GstElement *capsfilter = gst_element_factory_make("capsfilter", NULL);
            GstCaps *caps = gst_caps_new_simple("video/x-raw",
                            "format", G_TYPE_STRING, "NV12",
                            "width", G_TYPE_INT, 720,
                            "height", G_TYPE_INT, 576,
                            "framerate", GST_TYPE_FRACTION, 5, 1, NULL);
            g_object_set (capsfilter, "caps", caps, NULL);
        
            // convert to GL texture (as qmlglsink expects, also this force processing the video accelerated by the GPU)
            GstElement *glupload = gst_element_factory_make ("glupload", NULL);
        
            // convert from original video format NV12 to format accepted by qmlglsink (RGBA)
            GstElement *glcolorconvert = gst_element_factory_make ("glcolorconvert", NULL);
        
            // QML element sink
            /* 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 (sink, "sync", false, NULL);
        
            // link the elements in the pipeline
            gst_bin_add_many (GST_BIN (pipeline), src, capsfilter, glupload, glcolorconvert, sink, NULL);
            gst_element_link_many (src, capsfilter, glupload, glcolorconvert, sink, NULL);
        
        
        Pablo J. RoginaP 1 Reply Last reply
        1
        • N naggety

          I'm so sorry, I was testing some possible workarounds and I forgot this thread.

          What I've finally done is using Gstreamer (alone, not QTGstreamer) with qmlglsink element. In my case, I needed some fixes in Gstreamer that are going to be included in version 1.15 but it's working.

          About Camera QML element I still don't know if it's supposed to work with analog cameras. I think yes, but I haven't it working yet because I think my driver is a bit buggy, I'll try to fix it.

          I have tested using the QML example from Gstreamer, but modifying the pipeline to use my cameras instead of videotestsrc.

          This is the original example: https://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/tests/examples/qt/qmlsink?id=b03df1abf828514b0966db058388bf974ed0cf4f

          And this is the pipeline I've used:

              // Pipeline object
              GstElement *pipeline = gst_pipeline_new (NULL);
          
              // v4l2 src, selecting device /dev/video1
              GstElement *src = gst_element_factory_make("v4l2src", NULL);
              g_object_set (src, "device", "/dev/video1", NULL);
          
              // caps selection: format, width, height...
              GstElement *capsfilter = gst_element_factory_make("capsfilter", NULL);
              GstCaps *caps = gst_caps_new_simple("video/x-raw",
                              "format", G_TYPE_STRING, "NV12",
                              "width", G_TYPE_INT, 720,
                              "height", G_TYPE_INT, 576,
                              "framerate", GST_TYPE_FRACTION, 5, 1, NULL);
              g_object_set (capsfilter, "caps", caps, NULL);
          
              // convert to GL texture (as qmlglsink expects, also this force processing the video accelerated by the GPU)
              GstElement *glupload = gst_element_factory_make ("glupload", NULL);
          
              // convert from original video format NV12 to format accepted by qmlglsink (RGBA)
              GstElement *glcolorconvert = gst_element_factory_make ("glcolorconvert", NULL);
          
              // QML element sink
              /* 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 (sink, "sync", false, NULL);
          
              // link the elements in the pipeline
              gst_bin_add_many (GST_BIN (pipeline), src, capsfilter, glupload, glcolorconvert, sink, NULL);
              gst_element_link_many (src, capsfilter, glupload, glcolorconvert, sink, NULL);
          
          
          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @naggety great that you found a solution. If your issue is solved please don't forget to mark your post as such. Thanks

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • N Offline
            N Offline
            naggety
            wrote on last edited by
            #5

            Hi @Pablo-J-Rogina, it still remains the question about Camera element from QML. I'd wish to maintain open the post for some days more to see if I solve it and/or anybody can give me some help about it. If not, I will mark as solved in some days.

            Pablo J. RoginaP 1 Reply Last reply
            0
            • N naggety

              Hi @Pablo-J-Rogina, it still remains the question about Camera element from QML. I'd wish to maintain open the post for some days more to see if I solve it and/or anybody can give me some help about it. If not, I will mark as solved in some days.

              Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

              @naggety fair enough

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi,

                Might be silly question but, are you sure your pipeline is running properly ?

                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
                • N Offline
                  N Offline
                  naggety
                  wrote on last edited by
                  #8

                  Hi @SGaist.

                  Sorry, I didn't see your reply. I've changed my forum settings to receive an email when someone replies to my posts.

                  I guess that the pipeline is not running properly, but I can't know since I didn't made the pipeline. In my original post, I was using Camera QML element, and I have no control over the pipeline it tries to create.

                  In my later reply, I show a pipeline made by me that is working. But it's still no possible to use Camera QML element, which is supposed to handle all this automatically.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Did you consider using the QtGStreamer module directly ?

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

                    N 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Did you consider using the QtGStreamer module directly ?

                      N Offline
                      N Offline
                      naggety
                      wrote on last edited by naggety
                      #10

                      @SGaist I was considering it, but I read this:

                      The QtGStreamer C++ bindings are very out of date and unmaintained

                      here: https://gstreamer.freedesktop.org/bindings/qt.html

                      Do you think it worth to use it?

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Do you mean the qmlglsink ? Worth a try yes

                        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

                        • Login

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