Qt World Summit: Submit your Presentation

Subclassing a QVideoWidget

  • Hello everyone!

    I am using a QVideoWidget as a QCamera viewfinder and I need to access all the frames displayed on the video widget.
    In order to do that, I'd like to subclass the QVideoWidget and catch the frames before they are painted on the window.
    The QCameraViewfinder is a subclass of QVideoWidget, but it doesn't do any painting. QCameraViewfinder source code
    Also, it seems like the video frames are not accessible (see here), so subclassing the widget would not solve the problem. Maybe I could implement the paintEvent like this:

    VideoWidgetSubclass::paintEvent(QPaintEvent *event)
        QVideoWidget::paintEvent(event); // let's the QVideoWidget do the painting stuff
        // obtain the current frame by getting the surface of the widget?

    Is there a better solution? I even tried to implement a QAbstractVideoSurface, but the image I get is underexposed. That's why I want to use a QVideoWidget, because it automatically adjusts the exposure of the image (and allows changing the saturation, hue, etc.).

    Any help would be greatly appreciated.

  • Lifetime Qt Champion


    What exactly is your goal with these frames ?

  • I am writing a video conferencing app.
    I need a preview widget in which the frames will be displayed (I can do it with a QVideoWidget/QCameraViewfinder) but I also need to send each frame through the network.

  • Lifetime Qt Champion

    It's very similar to your other thread here, isn't it ?

  • It is, but in this one, I asked for a way to get the frames from a QVideoWidget and also display them at the same time.
    I'm sorry if I created two distinct threads, maybe I should have put all this in a single one.
    But this one is more important to me, do you think there's a way to get the frames from a QVideoWidget? As I told you, I need to preview them in a widget and also send them over the network (using UDP sockets), because I am making a video conferencing app.
    Skype, for instance, has a preview area so that users can see their own video, and the video is also sent using UDP sockets. That's what I want to achieve. My network protocol is ready for sending the data, but I need to get those video frames.

    Thank you for replying!

  • Lifetime Qt Champion

    See my answer to your other thread. For the network part, it looks like you are re-inventing the wheel by using a custom network protocol.

Log in to reply