Results 1 to 7 of 7

Thread: QGraphicsVideoItem crashes on video play

  1. #1
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsVideoItem crashes on video play

    Hi!

    I am trying to implement a zoom-able video playing, which is only possible by using QGraphicsVideoItem in a QGraphicssView, I have been told. This would be a basic example:


    Qt Code:
    1. QGraphicsView * graphicsView = new QGraphicsView;
    2. QMediaPlayer * player = new QMediaPlayer;
    3.  
    4. graphicsView->setScene(scene);
    5.  
    6. QGraphicsVideoItem *item = new QGraphicsVideoItem;
    7. player->setVideoOutput(item);
    8. graphicsView->scene()->addItem(item);
    9. graphicsView->show();
    10.  
    11. player->setMedia(QUrl::fromLocalFile("c:/x.mp4"));
    12. player->play();
    To copy to clipboard, switch view to plain text mode 


    however, it chokes on a debug assert:

    ---------------------------
    Microsoft Visual C++ Runtime Library
    ---------------------------
    Debug Error!

    Program: C:\Qt5\5.4\msvc2013_64\bin\Qt5Cored.dll
    Module: 5.4.1
    File: global\qglobal.cpp
    Line: 2868

    ASSERT: "m_surface" in file player\mfvideorenderercontrol.cpp, line 2342

    (Press Retry to debug the application)

    ---------------------------
    Abort Retry Ignore
    ---------------------------

    I looked into it, but I have no idea why the assert is fired.

    Q_ASSERT(m_surface);

    As far as i can tell, m_surface is non-NULL.



    Anyways, the crash also occurs when I just create a QGraphicsVideoItem without adding it to anything.


    Qt Code:
    1. QMediaPlayer * player = new QMediaPlayer;
    2. QGraphicsVideoItem *item = new QGraphicsVideoItem;
    3. player->setVideoOutput(item);
    4.  
    5. player->setMedia(QUrl::fromLocalFile("c:/x.mp4"));
    6. player->play();
    To copy to clipboard, switch view to plain text mode 


    i can only guess that the crash is related to the QGraphicsVideoItem not offering a proper surface to render the video on? Where do I go wrong?


    I am using Qt 5.4 + MSVC 2013 + Win7.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsVideoItem crashes on video play

    Do you have proper video backend for your platform installed?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsVideoItem crashes on video play

    Yes. I can play the video fine with a QVideoWidget.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsVideoItem crashes on video play

    Did you add the item to a scene? Aah, I see you did. Can you prepare a minimal compilable example reproducing the problem?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsVideoItem crashes on video play

    Sure!

    Just adjust the path to the mp4 file.

    Qt Code:
    1. #include <QWidget>
    2. #include <QtCore>
    3. #include <QtGui>
    4. #include <QtWidgets>
    5. #include <QtMultimedia>
    6.  
    7. #include <QGraphicsVideoItem>
    8.  
    9. int main(int argc, char *argv[])
    10. {
    11. QApplication a(argc, argv);
    12.  
    13. QMediaPlayer * player = new QMediaPlayer;
    14. QGraphicsVideoItem *item = new QGraphicsVideoItem;
    15. player->setVideoOutput(item);
    16. player->setMedia(QUrl::fromLocalFile("c:/x.mp4"));
    17. player->play();
    18.  
    19. return a.exec();
    20. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsVideoItem crashes on video play

    Well, here you are not adding the item to a scene.

    This works for me:

    Qt Code:
    1. #include <QApplication>
    2. #include <QMediaPlayer>
    3. #include <QGraphicsVideoItem>
    4. #include <QGraphicsView>
    5. #include <QGraphicsScene>
    6.  
    7. int main(int argc, char *argv[])
    8. {
    9. QApplication a(argc, argv);
    10. QMediaPlayer * player = new QMediaPlayer;
    11. QGraphicsVideoItem *item = new QGraphicsVideoItem;
    12. player->setVideoOutput(item);
    13. player->setMedia(QUrl::fromLocalFile("/tmp/a/sintel_trailer-480p.mp4"));
    14. scene.addItem(item);
    15. view.setScene(&scene);
    16. view.show();
    17. player->play();
    18. return a.exec();
    19. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsVideoItem crashes on video play

    Both your and my snippet cause the described crash.

Similar Threads

  1. I cannot play a video using phonon
    By armin1359 in forum Newbie
    Replies: 0
    Last Post: 15th August 2013, 06:22
  2. Replies: 19
    Last Post: 13th May 2013, 11:17
  3. Phonon can't play the video
    By leegoe in forum Qt Programming
    Replies: 1
    Last Post: 8th June 2012, 02:45
  4. Play Video On Symbian
    By cuteatul in forum Qt Programming
    Replies: 2
    Last Post: 14th July 2011, 05:26
  5. Video play issue
    By baluk in forum Newbie
    Replies: 3
    Last Post: 4th December 2010, 13:43

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.