Important: Please read the Qt Code of Conduct -

layered video / graphics media player strategy

  • say i wish to create a media player with these features:

    • composition has transparency
    • comp is made of zero or more layers
    • each layer may be either animated graphics, still graphics, or video
    • comp may be sent to multiple "Displays" in realtime (eg: render once, display many)
    • comp may be piped to a file-storage routine (not necessarily realtime)

    what would be the best strategy for this?

    i see QGraphicsScene, and it seems like it might be the thing? each layer would be a QGraphicsItem? the "comp" would be the QGraphicsView? or would the comp actually be the QImage rendered by QGraphicsView? i don't want the scene rendered once for each Display, i'd like a cached image for that.

    Am i thinking along the right lines? Thoughts?

    update: another "layer" may be an editing mode, in that mode the layer may have a dozen graphical elements that may be selected or dragged around in groups or individually. seems like that might be a sub-scene? cuz i only want that layer's items to be editable (click-draggable).

    how do i bind the "view" to multiple windows, or to panels within a window?

    it seems that the "scene" is constructed by passing the window (view) into it? but then you create a view and pass the scene into that? the logic doesn't quite hang together in my mind

    eg: the constructor for my video window:

    	PREF_WindType	windType, 
    	QWidget			*parent
    ) :
    	ui(new Ui::VideoWindow)
    	QGraphicsView		*graphicsView = new QGraphicsView(new QGraphicsScene(this));
    	... ?

    but i want to create the scene and the view independent of the window (so i can show it in multiple windows or in a panel in a window), and just have the window or panel "subscribe" to its output...

  • it seems nobody has an opinion. which i guess is the "right" answer

  • Lifetime Qt Champion


    Just to be sure I understand correctly, are you trying to implement something like kdenlive ?

    On a side note, you should avoid prefixing your custom classes name with Q. It's going to be harder to maintain and people will try to look for these classes in Qt itself.

  • no i'm implementing a karaoke player, that allows for transparent animated graphics playing (so the words can appear over a user-selected background), or video (cuz some karaoke is just plain video), with overlays (like scrolling text across the bottom), and transcoding (eg: convert to mp4)

  • Lifetime Qt Champion

    Then I would say that QtQuick might be better fitted for that.

  • no, this is a QT Widgets app. i've already put years into it

  • it seems nobody has an opinion. which i guess is the "right" answer

  • my solution was to give up on caching the result of the scene rendering and sending it to multiple views, because i wanted to have different scenes (with different layers) displayed in each view.

    so yes: each view is a QGraphicsView, which has a QGraphicsScene, and each "layer" is presented as a QGraphicsItem in each separate scene. even a QMediaPlayer (movie) can be presented to multiple QGraphicsVideoItems, one per scene. so it all works out.


Log in to reply