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. Displaying a QVideoFrame in a QVideoWidget
Forum Updated to NodeBB v4.3 + New Features

Displaying a QVideoFrame in a QVideoWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 2 Posters 4.1k 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.
  • T Offline
    T Offline
    tomatoketchup
    wrote on last edited by tomatoketchup
    #1

    Hello everyone!
    I'm new here, and I've already got a question.

    I would like to display a QVideoFrame in a QVideoWidget, is it possible?
    I'm writing a video conferencing app, and I need an efficient way to display QVideoFrames as I may need to display a few ones at the same moment (from multiple users).

    I have already tried converting the video frame to a QImage and then displaying it in a QLabel, but the frame was upside down. Here's the code I used:

    QVideoFrame vf(frame); // frame is a QVideoFrame probed by a QVideoProbe
    
    vf.map(QAbstractVideoBuffer::ReadOnly);
    QImage img(vf.bits(), vf.width(), vf.height(), QVideoFrame::imageFormatFromPixelFormat(vf.pixelFormat()));
    m_label->setPixmap(QPixmap::fromImage(img));
    vf.unmap();
    

    I guess that doing it with a QVideoWidget would be much more efficient because that's the purpose of it, but I don't see how it works. I found an example of its usage, but it has nothing to do with what I want to do (displaying a QVideoFrame).

    I'm using Qt 5.11 on Windows 8.1, with MSVC 2015.

    Any help would be greatly appreciated.

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

      Hi,

      Where are you video frames coming from ?

      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
      • T Offline
        T Offline
        tomatoketchup
        wrote on last edited by
        #3

        Thanks for the reply.
        I'm sorry for the very late answer, I didn't get any notification and I completely forgot this topic..

        My frames are coming from a QVideoProbe attached to a QCamera.

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

          Why not use the QCameraViewFinder ?

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

            I can use it, but I need to send the video over the network.
            I there a way to grab the QVideoFrames using the QCameraViewfinder?

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

              How do you want to send your video frames over the network ?

              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
              • T Offline
                T Offline
                tomatoketchup
                wrote on last edited by
                #7

                I would like to convert them to QImages and send the bits, the format and other things via QUdpSockets and build the images back again.
                I can do the conversion stuff and it works perfectly, but I need an efficient way to grab the frames from a viewfinder.

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

                  Shouldn't you rather use a known streaming format for 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
                  • T Offline
                    T Offline
                    tomatoketchup
                    wrote on last edited by
                    #9

                    Do you mean I should use a format like AVI, MP4, MOV or WMV?
                    Can't I just send the video frames raw data?

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

                      No those are video file format and/or containers.

                      I mean streaming as described in this basic gstreamer tutorial.

                      You even have the QtGstreamer module that would allow you to setup more easily a system that can both show your video on screen and stream it over the network.

                      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
                      • T Offline
                        T Offline
                        tomatoketchup
                        wrote on last edited by
                        #11

                        Thanks for your help!

                        I didn't know GStreamer, I'm going to check this out.

                        Once I have solved my problem, I will post my solution here and mark the thread as solved.

                        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