Important: Please read the Qt Code of Conduct -

QMediaResource, getting any media info failed

  • Hi! I'm trying to obtain media info from QMediaResource class methods.
    Please check this code.
    QMediaResource mr(QUrl::fromLocalFile("test.avi"));
    QMediaContent mc(mr);

    QMediaPlayer player = new QMediaPlayer(this);
    QViedoWidget vw = new QVideoWidget;

    qDebug() << mr.resolution() << mr.videoCodec();@

    Video plays well. QMediaResource url returns right path to file.
    QMediaResource methods resolution(), videoCodec(), sampleRate() etc. returns 0 or empty values.
    Can anyone confirm this? Please run this simple example on your installation.
    Or I do something wrong?

    I'm using Qt5 on Windows7.

  • Moderators

    Your code looks ok to me.

    Try it on some other video types (for example, .mp4 and .mov files). Do they work? I've had some strange behaviour from Qt Multimedia on Windows, and often have trouble with .avi files... I believe the class is broken somewhere.

  • Thanks for your time. I checked on different kinds of containers and codecs (.avi, .mp4, .wmv and .mov). The same result - it seems to be bug. Let it be here for some more time and if nobody has positive result I will try report as bug.

  • Reply from developers:
    "This class doesn't actually do anything at the moment... As a workaround, you can use QMediaPlayer::metadata() to get this information.
    Note that with Qt 5.0 and on Windows 7, even the metadata() function doesn't retrieve this information, it will be fixed in 5.0.1"


Log in to reply