Slow Performance of QMediaPlayer with QGraphicsView/QGraphicsVideoItem/QGraphicsScene
-
Hello,
So, I am trying to build a video player which a nice interface.
What I have been able to successfully do so far is getting QMediaPlayer to display the video on a QGraphicsVideoItem with transparent controls on top of it. The result looks pretty nice with gthe following exceptions:
- The resultant output is displayed but with just the "blue channel" shown; it's like instead of greyscale it's "blue scale".
- The performance of the video is very slow; the resultant player takes up 50% and more of CPU power and the video is very choppy.
What can I do to increase the performance of the player while also keeping the transparent widgets?
Also, what can I do to correct the color output?
Thank you.
Here is my "prepareUI()" function that is called in my main window's constructor:
void QTVideoPlayer::prepareUI(QUrl initialURL) { MainGraphicsView = new QGraphicsView(); MainGraphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); MainGraphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); MainGraphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); this->setCentralWidget(MainGraphicsView); MainGraphicsPlayerArea = new QGraphicsVideoItem(); MainGraphicsPlayerArea->setSize(MainGraphicsView->size()); MainVideoPlayer = new QMediaPlayer(); MainVideoPlayer->setVideoOutput(MainGraphicsPlayerArea); MainGraphicsScene = new QGraphicsScene(0, 0, MainGraphicsView->size().width(), MainGraphicsView->size().height()); MainGraphicsView->setScene(MainGraphicsScene); MainGraphicsView->scene()->addItem(MainGraphicsPlayerArea); MainPlayList = new QMediaPlaylist(MainVideoPlayer); MainPlayList->addMedia(initialURL); MainPlayList->setCurrentIndex(0); MainVideoPlayer->setPlaylist(MainPlayList); MainVideoPlayer->setNotifyInterval(100); MainVideoPlayer->play(); MainVideoPlaylist = new QTVideoPlaylist(); MainVideoPlaylist->setParent(this); resizeVideoPlaylistWidget(); MainVideoPlaylist->show(); MainVideoControls = new QTVideoControls(); MainVideoControls->setParent(this); resizeVideoControlsWidget(); MainVideoControls->show(); videoControlsShown = true; videoPlaylistShown = true; }