PDA

View Full Version : Flickering video when looping using QGraphicsView



spmyn
11th May 2016, 11:00
Hello,

I have a project that needs to display QLabel on top of a video. In order to do so, I figured out that I should use QGraphicsView to display a video.

Here is my code:



player = new QMediaPlayer;
playlist = new QMediaPlaylist(player);

item = new QGraphicsVideoItem;
playlist->addMedia(QUrl::fromLocalFile("path/to/video"));
playlist->setCurrentIndex(0);
playlist->setPlaybackMode(playlist->Loop);
player->setPlaylist(playlist);
player->play();
player->setVideoOutput(item);
scene = new QGraphicsScene;
ui->graphicsView->setScene(scene);
ui->graphicsView->scene()->addItem(item);


Everything works fine. The problem is my video runs in a loop and it flickers every time it starts a new loop.

How can I make it run smoothly?

d_stranz
11th May 2016, 17:03
It would help if you gave a little context that shows where this code is being executed. It obviously isn't your real code - line 7, for example, is a syntax error.

spmyn
12th May 2016, 05:23
I am using Qt 5.6 MinGW 32bit on Win10 64bit.
I have installed K-Lite Codec and LAVFilters.

That piece of code is in mainwindow.cpp. graphicsView is set in Ui.

I have changed line 7 to


playlist->setPlaybackMode(QMediaPlaylist::Loop);

but appears the same issue.

I have also tried setMedia to player instead of addMedia to playlist but video doesn't appear at all.
Now I can show the video using addMedia with playlist and with flickering issue when the loop ends.

I don't know if this relates but I have this error both with setMedia and addMedia:


DirectShowPlayerService::doRender: Unresolved error code 80040200

However the video shows (if using addMedia)

d_stranz
12th May 2016, 17:53
That piece of code is in mainwindow.cpp. graphicsView is set in Ui.

Great. Now where in mainwindow.cpp does that code appear?