QML Video alpha blending / rendering video into a Qt fast scene graph

I am trying to get alpha blending effect in QML with video in RGBA.

Now the problem is that the video element provided by QtMultimedia actually opens the overlay window in the QtQuick frame, so I donโ€™t think it is possible to alpha mix other QML elements with the Video element (I hope I am wrong, but I canโ€™t find decision).

So another way is to render the video in a class that inherits from QQuickItem in the updatePaintNode method.

  • Has anyone seen anything like this before? Is it possible if the guys from QtMultimedia can not achieve this?

  • Can I change the background of a MediaPlayer element, maybe be transparent or just a color in QML?

So far I have been thinking about QAbstractVideoSurface and QVideoFrame, but I have no idea how to display it on QSG or even how GeometryNode is looking for video.

A better solution would be to get alpha blending with other QML elements, for example:

Rectangle { width: 1024 height: 768 color: "yellow" focus: true Video { id: video anchors.fill: parent source: "alpha-video.mov" autoPlay: true } } 

Thanks in advance!

+7
qt alphablending qml qtquick2
source share
1 answer

I tried a few things, but in the end I used a Qt example called VideoWidget that uses QAbstractVideoSurface and QVideoFrame, and drew frames in QQuickPaintedItem using MediaPlayer to load data from QML.

It is important to put ARGB32 on top of the QList, which describes the supported pixel formats in QAbstractVideoSurface, unfortunately, Qt's logic is that they take the first format availibe and why the native video element does not show the alpha channel (it plays the video in RGB32, either this or thing with an overlay window in the native element, and not draw it in the QtQuick scene graphics).

+2
source share

All Articles