Results 1 to 4 of 4

Thread: Flickering video when looping using QGraphicsView

  1. #1
    Join Date
    Feb 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Flickering video when looping using QGraphicsView

    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:


    Qt Code:
    1. player = new QMediaPlayer;
    2. playlist = new QMediaPlaylist(player);
    3.  
    4. item = new QGraphicsVideoItem;
    5. playlist->addMedia(QUrl::fromLocalFile("path/to/video"));
    6. playlist->setCurrentIndex(0);
    7. playlist->setPlaybackMode(playlist->Loop);
    8. player->setPlaylist(playlist);
    9. player->play();
    10. player->setVideoOutput(item);
    11. scene = new QGraphicsScene;
    12. ui->graphicsView->setScene(scene);
    13. ui->graphicsView->scene()->addItem(item);
    To copy to clipboard, switch view to plain text mode 


    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?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,348
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: Flickering video when looping using QGraphicsView

    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.

  3. #3
    Join Date
    Feb 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Flickering video when looping using QGraphicsView

    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

    Qt Code:
    1. playlist->setPlaybackMode(QMediaPlaylist::Loop);
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. DirectShowPlayerService::doRender: Unresolved error code 80040200
    To copy to clipboard, switch view to plain text mode 

    However the video shows (if using addMedia)

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,348
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: Flickering video when looping using QGraphicsView

    That piece of code is in mainwindow.cpp. graphicsView is set in Ui.
    Great. Now where in mainwindow.cpp does that code appear?

Similar Threads

  1. Qt - Overlay QGraphicsView over vlc video
    By m1lhaus in forum Qt Programming
    Replies: 9
    Last Post: 6th July 2013, 12:45
  2. Counting and looping properties
    By stefan in forum Qt Programming
    Replies: 2
    Last Post: 25th January 2011, 14:38
  3. Replies: 0
    Last Post: 8th April 2010, 12:08
  4. Simulating Video on QLabel or QGraphicsView
    By forrestfsu in forum Qt Programming
    Replies: 9
    Last Post: 21st March 2007, 11:39
  5. QtKey looping
    By VireX in forum Newbie
    Replies: 4
    Last Post: 15th February 2007, 21:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.