Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Slow Performance of QMediaPlayer with QGraphicsView/QGraphicsVideoItem/QGraphicsScene
QtWS25 Last Chance

Slow Performance of QMediaPlayer with QGraphicsView/QGraphicsVideoItem/QGraphicsScene

Scheduled Pinned Locked Moved General and Desktop
qmultimediaqmediaplayer
1 Posts 1 Posters 2.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tmason202
    wrote on last edited by
    #1

    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;
    
    }
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved