Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

hardware video playback to multiple surfaces?



  • say i'm using QMediaPlayer to playback video onto a single QAbstractVideoSurface.
    is that done in hardware? ie: the bits never have to be pushed back to the CPU?
    and then can i blit said surface to multiple widgets? in which case it STILL stays on the hardware?
    must i use an opengl widget as the destination surface?

    like i have two video windows (dedicated to video, which may be maximized full screen on a 4K monitor), and one "monitor" panel embedded in a larger GUI window with other controls in it. i want all three to display the same HD video at full framerate, and have text overlays too... can i do that without ever having the video bits come thru the CPU?



  • I've learned how to do it.

    • You have multiple QGraphicsView objects (maybe in different windows).
    • You can cause them to use OpenGL by calling setViewport() passing in a new QOpenGLWidget
    • Each of those has a QGraphicsScene
    • Each of those has a QGraphicsVideoItem element in the scene
    • Each of those has a QAbstractVideoSurface, fetched with videoSurface()
    • The QMediaPlayer can set it's output to go to ALL of the video surfaces at once, by passing a vector of them to its setVideoOutput()

    Does that make sense?


  • Lifetime Qt Champion

    Hi,

    AFAIK, it will depend on several factors like the OS, the backend used and whether you are using widgets or QtQuick.

    You can customize some parts however the first thing to establish is what is your target platform.



  • macOS and Windows, using Widgets



  • Does anybody know the answer to this?


  • Lifetime Qt Champion

    I remember that Qt Quick video elements use OpenGL for rendering but AFAIR, it was not the case by default for widgets. So that is something you'll have to test.



  • I've learned how to do it.

    • You have multiple QGraphicsView objects (maybe in different windows).
    • You can cause them to use OpenGL by calling setViewport() passing in a new QOpenGLWidget
    • Each of those has a QGraphicsScene
    • Each of those has a QGraphicsVideoItem element in the scene
    • Each of those has a QAbstractVideoSurface, fetched with videoSurface()
    • The QMediaPlayer can set it's output to go to ALL of the video surfaces at once, by passing a vector of them to its setVideoOutput()

    Does that make sense?


  • Lifetime Qt Champion

    Sounds correct

    One thing that comes to mind, if you are showing the same video feed, why not have only one scene and several views on it ?



  • because one view may (or may not) have the overlaid text, and another may not even be showing the video, may be showing a "who's up next" screen, depending on user-prefs

    it's configurable to show the exact same thing on all screens, but ALSO configurable to show different things on different screens.

    -dave


  • Lifetime Qt Champion

    I do not know the interaction that you may have a need for with the other components but you can likely do everything in one scene and then just move the "focus point" of the view in the right place of that big scene.


Log in to reply