Results 1 to 3 of 3

Thread: Playing MP4 and FLV with QMediaPlayer

  1. #1
    Join Date
    Jul 2013
    Posts
    16
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Playing MP4 and FLV with QMediaPlayer

    Good day everyone!

    background info
    All machines mentioned below are Win 7 Pro
    Using Qt 5.0.2

    I am trying to do as the title says, I am using the QMediaPlayer and QVideoWidget to try and play video.

    Here is the code:
    Qt Code:
    1. //should be noted that mp4 are encoded with h264
    2. QUrl filename = QUrl::fromLocalFile("sampleFile.mp4");
    3. QMediaPlayer *mMediaPlayer = new QMediaPlayer();
    4. QVideoWidget *mVideoWidget = new QVideoWidget(this);
    5.  
    6. this->setCentralWidget(mVideoWidget); //where this is the mainwindow
    7.  
    8. mMediaPlayer->setMedia(filename);
    9.  
    10. qDebug() << "Player error state -> " << mMediaPlayer->error(); //this says no error
    11. qDebug() << "Media supported state -> " << QMediaPlayer::hasSupport("video/mp4"); // this gives a "1"
    12.  
    13. this->show();
    14. mMediaPlayer->play();
    To copy to clipboard, switch view to plain text mode 
    The trick is this, I can put this on several different machines — all are Windows 7 Pro:
    1.) machine 1 — development box, can play some mp4s but not others (all h264)
    2.) machine 2 — personal household box, will play the sampleFile mp4 sometimes
    3.) machine 3 — COMPLETELY clean windows 7 pro install, aside from the code above, has nothing installed on it, NEVER plays the mp4.

    All 3 machines can play the sampleFile.mp4 in Windows Media Player.

    As a final note, none of these will play FLV either.

    Pointers anyone? What am I missing here?
    Last edited by JasonKretzer; 11th September 2013 at 22:51. Reason: updated contents

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,671
    Thanks
    13
    Thanked 1,595 Times in 1,523 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Playing MP4 and FLV with QMediaPlayer

    The ability to play format X on Windows requires a Windows codec for format X installed the machine. Default codecs vary from Windows version to version and between Home, Pro, and Ultimate editions etc. Chances are that if Microsoft's media player cannot play the file then Qt will not be able to either.

    The FLV container may contain video encoded with Sorenson Spark, VP6, or H.264 codecs, and audio in either the Shockwave Flash format or AAC.

  3. The following user says thank you to ChrisW67 for this useful post:

    JasonKretzer (12th September 2013)

  4. #3
    Join Date
    Jul 2013
    Posts
    16
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Playing MP4 and FLV with QMediaPlayer

    Quote Originally Posted by ChrisW67 View Post
    The ability to play format X on Windows requires a Windows codec for format X installed the machine. Default codecs vary from Windows version to version and between Home, Pro, and Ultimate editions etc. Chances are that if Microsoft's media player cannot play the file then Qt will not be able to either.

    The FLV container may contain video encoded with Sorenson Spark, VP6, or H.264 codecs, and audio in either the Shockwave Flash format or AAC.
    Thats just it, the mp4 plays in windows media player. I have installed the K-lite codec pack as well. All to no avail, still getting the black box

Similar Threads

  1. QMediaPlayer Questions
    By morpheus in forum Newbie
    Replies: 1
    Last Post: 25th August 2013, 15:03
  2. QMediaplayer setposition is wrong
    By oldkkk2008 in forum Qt Programming
    Replies: 1
    Last Post: 11th March 2013, 11:58
  3. QMediaPlayer problems
    By alenn.masic in forum Qt Programming
    Replies: 1
    Last Post: 25th February 2013, 16:32
  4. QMediaPlayer repeat sound
    By alenn.masic in forum Qt Programming
    Replies: 0
    Last Post: 21st February 2013, 15:46
  5. QMediaPlayer seeking in stream
    By n1ghtly in forum Qt Programming
    Replies: 0
    Last Post: 24th August 2012, 14:28

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.