[Interest] Playing MP4 and FLV with QMediaPlayer

Jason Kretzer Jason at gocodigo.com
Wed Sep 11 23:45:04 CEST 2013


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:
Switch view
 //should be noted that mp4 are encoded with h264
 QUrl filename = QUrl::fromLocalFile("sampleFile.mp4");
 QMediaPlayer *mMediaPlayer = new QMediaPlayer();
 QVideoWidget *mVideoWidget = new QVideoWidget(this);
  
 this->setCentralWidget(mVideoWidget); //where this is the mainwindow
  
 mMediaPlayer->setMedia(filename);
  
 qDebug() << "Player error state -> " << mMediaPlayer->error(); //this says no error
 qDebug() << "Media supported state -> " << QMediaPlayer::hasSupport("video/mp4"); // this gives a "1"
  
 this->show();
 mMediaPlayer->play();

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?

Thanks!

-Jason








More information about the Interest mailing list