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. GStreamer with Qt under Linux. Video appears only after application window is moved.
QtWS25 Last Chance

GStreamer with Qt under Linux. Video appears only after application window is moved.

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

    I have Qt 4.8.4 & GStreamer 1.0.5. I am using GStreamer's Video Overlay to display video from a cam in a Qt application.
    Once I start the GStreamer pipeline, the webcam LED lights up but I can't see the video. The video appears only after I move the application window around a bit. The relevant part of the code is
    @
    cam_window = new QWidget(this);
    cam_window->setFixedWidth(640);
    cam_window->setFixedHeight(480);
    ...
    ...
    ...
    caps = gst_caps_new_simple("video/x-raw",
    "width", G_TYPE_INT, 640,
    "height", G_TYPE_INT, 480,
    NULL);
    pipeline = gst_pipeline_new ("pipeline");
    source = gst_element_factory_make ("v4l2src", "source");
    sink = gst_element_factory_make ("xvimagesink", "sink");

    gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
    gst_element_link_filtered (source, sink, caps);

    cam_winid = cam_window->winId();
    gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY (sink), cam_winid);
    @
    Once the video feed has started, setting the pipeline to PAUSED and PLAYING works just fine. It is only when the pipeline is first started that I face this problem.

    • I face the same problem when I set source as "videotestsrc" instead of "v4l2src".
    • Repainting (QWidget::repaint()) or Updating(QWidget::update()) the widget after starting the pipeline doesn't fix the problem.
    • Using QGraphicsView instead of QWidget doesn't solve the problem either.

    Any suggestions? What can I try doing differently?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      Have you tried to build the same pipeline using gst-launch?
      Does it show video immediately?

      @
      gst-lauch-1.0 -v -e v4l2src ! xvimagesink
      @

      Also you can check what gstreamer is doing by setting environment variable GST_DEBUG before starting your app.
      Set it to 3 or more if 3 does not produce enough info.

      something like this
      @
      GST_DBUG=3 ./your_app
      @

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andreyc
        wrote on last edited by
        #3

        The latest Gstreamer version is 1.2.3
        I would suggest to switch to it if you don't have any restrictions about it.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mndar
          wrote on last edited by
          #4

          [quote author="andreyc" date="1394209581"]
          Does it show video immediately?
          @gst-lauch-1.0 -v -e v4l2src ! xvimagesink@
          [/quote]
          Yes, it shows video immediately.

          [quote author="andreyc" date="1394209581"]
          Set it to 3 or more if 3 does not produce enough info.
          @GST_DEBUG=3 ./your_app@
          [/quote]
          Nothing useful. Just INFO messages.

          Adding a bus_sync_handler like the one given in the Gtk+ example on http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-gstvideooverlay.html seems to solve the problem.
          I need multiple overlays in my Qt application. I'm not sure how to modify the bus_sync_handler to work in that case.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andreyc
            wrote on last edited by
            #5

            If you need to display the same source in the multiple widgets then you can create multiple pipelines or use some plugin that allows to split video stream Maybe tee pluging but I'm not sure.
            Take a look on the "examples":http://wiki.oz9aec.net/index.php/Gstreamer_cheat_sheet maybe you will find something useful there.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mndar
              wrote on last edited by
              #6

              Setting a bus sync handler with gst_bus_set_sync_handler (...) and setting the video overlay with gst_video_overlay_set_window_handle(...) on the prepare_video_handle message solved the problem.
              The code from the link in my previous post works nicely.

              Thanks for your inputs anderyc.

              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