Unsolved Displaying a QVideoFrame in a QVideoWidget
-
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.
-
Hi,
Where are you video frames coming from ?
-
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.
-
Why not use the QCameraViewFinder ?
-
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? -
How do you want to send your video frames over the network ?
-
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. -
Shouldn't you rather use a known streaming format for that ?
-
Do you mean I should use a format like AVI, MP4, MOV or WMV?
Can't I just send the video frames raw data? -
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.
-
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.