3

I'm trying to play a movie using the QT Multimedia framework (5.0.1), but I only get a black screen with a mov coded with H.264.

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QWidget *mainWidget = new QWidget();
    mainWidget->setGeometry(0,0, 1920, 1080);

    QVideoWidget *widget = new QVideoWidget(mainWidget);
    widget->setGeometry(0, 0, 1920, 1080);

    QMediaPlayer *player = new QMediaPlayer;
    QUrl localUrl = QUrl::fromLocalFile("test_mov.mov");
    player->setMedia(localUrl);
    qDebug() << "Player error state -> " << player->error();
    qDebug() << "Media supported state -> " << QMediaPlayer::hasSupport("video/mov");
    player->setVideoOutput(widget);

    mainWidget->show();

    player->play();

    return a.exec();
}

The code compiles correctly and gives the following output on console, while the video widget remains black:

Player error state -> QMediaPlayer::NoError
Media supported state -> 1 // means "Probably supported"

I'm using Qt 5.0.1 on a Mac OSX 10.7.5. The file is correctly played by the player and ffmpeg -i test_mov.mov gives

Duration: 00:00:02.52, start: 0.000000, bitrate: 63708 kb/s Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080, 63684 kb/s, SAR 1745:1920 DAR 349:216, 25 fps, 25 tbr, 25 tbn, 50 tbc

Does anyone knows what are the formats supported by QT Multimedia ?

Thank you

4

1 回答 1

0

在 Windows 中,QT 视频文件格式通常带有 .mov 文件扩展名。QuickTime 本身(在不同程度上)支持的其他文件格式包括 AIFF、WAV、DV、MP3 和 MPEG-1。

于 2014-05-09T15:06:03.580 回答