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. Qt with opencv and gstreamer not working

Qt with opencv and gstreamer not working

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 1.6k Views 2 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.
  • S Offline
    S Offline
    ShahShaj
    wrote on last edited by
    #1

    Hi
    I am new to Qt world and am struggling with Qt - opencv - gstreamer pipeline model.
    I have a .mov file and I need to send it via udp using gstreamer to receiver side. Both sender and receiver written as Qt Application. This is a small portion of one Qt project, so I need to include both sender and receiver in Qt Application.
    I have gstreamer installed on my machine and on command line I am able to send and receive video file using following command.
    On sender side:
    gst-launch-1.0 filesrc location=path/to/.mov ! qtdemux name=demux demux.video_0 ! queue ! decodebin ! videoconvert ! jpegenc ! rtpjpegpay ! udpsink host=127.0.0.1 port=5000
    On receiver side:
    gst-launch-1.0 udpsrc port=5000 ! application/x-rtp,encoding-name=JPEG,payload=96 ! rtpjpegdepay ! jpegparse ! jpegdec ! videoconvert ! autovideosink
    It displays video with flickering. But atleast I am able to send and receive video with flickering.

    But when I try to include this gstreamer pipeline in Qt application as below its not working:
    On sender side:
    cap = new cv::VideoCapture("path\to.mov",cv::CAP_GSTREAMER);
    unsigned int width = _cap->get(cv::CAP_PROP_FRAME_WIDTH);
    unsigned int height = _cap->get(cv::CAP_PROP_FRAME_HEIGHT);
    unsigned int fps = _cap->get(cv::CAP_PROP_FPS);
    _writer = new cv::VideoWriter("appsrc ! qtdemux name=demux demux.video_0 ! queue ! decodebin ! videoconvert ! jpegenc !
    rtpjpegpay ! udpsink host=127.0.0.1 port=5000",
    cv::CAP_GSTREAMER,
    0, // fourcc 0 to send raw video
    fps, // fps
    cv::Size(width, height),
    true);
    connect(&_timer2, SIGNAL(timeout()), this, SLOT(sendVideoStream()));
    void Sender::sendVideoStream()
    {
    cap->read(frame);
    _writer->write(frame);
    }
    It throws error:
    [ WARN:0] global E:\opencv\4_2_with_tracker\opencv\modules\videoio\src\cap_gstreamer.cpp (1665) cv::CvVideoWriter_GStreamer::writeFrame OpenCV | GStreamer warning: Error pushing buffer to GStreamer pipeline
    On Receiver side:
    Inside main:
    QMediaPlayer* player =new QMediaPlayer;
    player->setMedia(QUrl("gst-pipeline: udpsrc port=5000 ! application/x-rtp,encoding-name=JPEG,payload=96 ! rtpjpegdepay ! jpegparse ! jpegdec ! videoconvert ! autovideosink"));
    Its not showing anything. Further instead of autovideosink I need to use appsink and display video in HMI using qml. That part also I need to solve.
    Any kind help will be highly appreciated.
    I am using Qt Creator 4.13.2 - Qt 5.15.1 (MSVC 2019, 64 bit) - opencv 4.2
    @SGaist

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

      Hi and welcome to devnet,

      Since you seem to be working on Windows, did you build the QtMultimedia 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

      1 Reply Last reply
      0
      • S Offline
        S Offline
        ShahShaj
        wrote on last edited by
        #3

        @SGaist Thank you for the kind reply.
        I didn't knew it. So I need to build Qt with Gstreamer support.
        What about the sender error
        [ WARN:0] global E:\opencv\4_2_with_tracker\opencv\modules\videoio\src\cap_gstreamer.cpp (1665) cv::CvVideoWriter_GStreamer::writeFrame OpenCV | GStreamer warning: Error pushing buffer to GStreamer pipeline ??
        Is the implementation I am using is correct?

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

          Not the whole of Qt, just the QtMultimedia plugin. I don't think you even need to rebuild QtMultimedia.

          As for the OpenCV error, the OpenCV forum will likely be a better place to get an answer about that.

          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
          • S Offline
            S Offline
            ShahShaj
            wrote on last edited by
            #5

            I don't think you even need to rebuild QtMultimedia.
            Instead of using QtMultimedia, qmlglsink will be a better option?
            Thanks again for your reply @SGaist

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

              @ShahShaj said in Qt with opencv and gstreamer not working:

              Instead of using QtMultimedia, qmlglsink will be a better option?

              Worth a try indeed.

              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