Qt (5): visualize the same video on two different surfaces using QtMultimedia

I am developing an application in Qt (5) and basically Im trying to display the same video source in 2 locations in my window using QtMultimedia5. I do this in QML, but if there is a solution in C ++, I will be happy to implement it.

I have no problem showing the video in a window. Problems arise when I try to use the same QMediaSource, but expose it to 2 windows / controls.

What I see is that QMediaService :: requestControl is called, which returns a QVideoRendererControl object. Then QVideoRendererControl :: setSurface is called to set the surface on which it displays the video. So, from what I collect, QMediaService has one surface on which it displays video at any given time.

How can I display on 2 surfaces or more? Are there other classes that better suit my needs?

Greetings

+4
source share
1 answer

Well, that was pretty simple, but not the way I expected. You must love QtQuick2.

So, I have a MediaPlayer source and a VideoOutput element in my QML code:

MediaPlayer { id: mp1 source: "slide-1.wmv" } VideoOutput { id: tbltSlides anchors.fill: parent visible: true source: mp1 } 

All I had to do was just add a ShaderEffectSource and set tbltSlides as the source. So simple:

 ShaderEffectSource { id: slides x: 600 width:250 height: 250 sourceItem: tbltSlides visible: true } 

EDIT: Obviously, in order to get the best quality, you need the tbltSlides element to be larger than the ShaderEffectSource, so that the shader reduces the original image.

+6
source

Source: https://habr.com/ru/post/1438864/


All Articles