PDA

View Full Version : Playing MP4 and FLV with QMediaPlayer



JasonKretzer
11th September 2013, 18:08
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:

//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?

ChrisW67
12th September 2013, 21:40
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.

JasonKretzer
12th September 2013, 21:58
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 :)