Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

ASSERT: “m_surface” when playing video



  • Hi,

    I am having a problem when trying to display a video in a QGraphicsview on Windows. I am constantly getting an assert in debug

    Program: c:\Qt\Qt5.3.2\5.3\msvc2013_64_opengl\bin\Qt5Cored.dll
    Module: 5.3.2
    File: global\qglobal.cpp
    Line: 2127

    ASSERT: “m_surface” in file player\mfvideorenderercontrol.cpp, line 2349

    Which I can ignore and it will work, however in release mode, it crashes instead.

    Is there some call that I should be making prior to ensure that m_surface is never null by the time it hits this line?
    more informations:
    Os: windows 8.1 64 bit

    this is snip of my code
    @ QGraphicsScene *scene;
    QMediaPlayer mp;
    QGraphicsVideoItem v;
    scene = new QGraphicsScene;
    ui->graphicsView->setScene(scene);
    QStringList list;
    list <<QString("D:/files/3240/mov/1.mov") << QString("D:/files/3240/videos/newmov/1.mov")<<
    QString("D:/files/3240/videos/3.mov")<< QString("D:/files/3240/videos/4.mov")
    <<QString("D:/files/3240/videos/5.mov");
    mp.setVideoOutput(&v);
    mp.setMedia(QUrl::fromLocalFile(list.at(i%5)));
    mp.play();
    mp.setVolume(0);
    scene->addItem(&v);@


  • Lifetime Qt Champion

    Hi,

    Where's that code called from ?



  • in the Button click event



  • this is my code
    @#include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QDebug>

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    i = 0;
    scene = new QGraphicsScene;
    ui->graphicsView->setScene(scene);
    // setWindowFlags(Qt::FramelessWindowHint);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::resizeEvent(QResizeEvent *)
    {

    }

    void MainWindow::mousePressEvent(QMouseEvent *)
    {

    }

    void MainWindow::on_pushButton_clicked()
    {
    resize(1080,400);
    QStringList list;
    list <<QString("D:/files/3240/mov/1.mov") << QString("D:/files/3240/videos/newmov/1.mov")<<
    QString("D:/files/3240/videos/3.mov")<< QString("D:/files/3240/videos/4.mov")
    <<QString("D:/files/3240/videos/5.mov");
    mp.setVideoOutput(&v);
    mp.setMedia(QUrl::fromLocalFile(list.at(i%5)));
    mp.play();
    mp.setVolume(0);
    scene->addItem(&v);
    //v->setSize(QSize(width(),height()));
    i++;
    }
    @


  • Lifetime Qt Champion

    What is w ?



  • w? didn't exist any w in this code. but if your mean is v.
    v is QGraphicsVideoItem and mp is QMediaPlayer


  • Lifetime Qt Champion

    What happens if you start playing only after adding v to the scene ?



  • at this time it show me the mention assert error


  • Lifetime Qt Champion

    Since Qt 5.4 has been released, can you check if you still encounter this problem ?



  • yes , i don't have any idea to solve it


  • Lifetime Qt Champion

    Yes you will test or yes you still have this problem ?



  • both, i tested Qt5.4 and the error exist in Qt 5.4


  • Lifetime Qt Champion

    Where's the assert located this time ?

    Did you install the latest driver for your graphic card ?



  • i update my graphic card again and the assert error does exist yet :( . what should i do to solve it?


  • Lifetime Qt Champion

    @
    mp.setVideoOutput(&v);
    scene->addItem(&v);
    @

    I'd move that in the constructor, there's no need to do that again each time.


Log in to reply