Qt5 with QMediaPlayer and QVideoWidget
-
Hello friends.
I`m using Windows 7 with "Qt5.0.0-beta2 binary install":http://releases.qt-project.org/qt5.0/beta2/qt-windows-opensource-5.0.0-beta2-msvc2010_32-x86-offline.exe.
I run simplified example of player (from examples) using QMediaPlayer and QVideoWidget. For most of the files I'm trying to play I got errors like "handleSessionEvent: serious error = -1072875852" or "handleSessionEvent: serious error = -2147467262" or no errors but without visual result. I used 4 files for testing. Two - avi with mpeg4 inside, one - mp4 with mpeg4 and one mpg with mpeg1 inside.
Only one avi file is played by code but they all are played well with Windows Media Player and Media Player Classic.
And I can't get any metadata from media - player->availableMetaData() returns empty list.
I have several questions:- Is QMultimedia part of Qt5 ready for "real use"? (I run examples from qmultimedia on my different video files and they almost all behave with the same result)
- What codecs are used by QMediaPlayer?
- How can I get info from video file?
- What is the best practice to open and parse video files in Qt?
- What "backends" are used in case QVideoWidget and in QMultimedia totally? (OpenGL, DirectShow or what?) I'm running on Windows 7.
- Is there posibility to switch "backends"? I want to use OpenGL and shaders to accelerate video output.
The code itself:
@#include <QDebug>
#include <QApplication>
#include <QMediaPlayer>
#include <QVideoWidget>
#include <QVBoxLayout>
#include <QFile>int main(int argc, char** argv)
{
QApplication app(argc, argv);QWidget *widget = new QWidget; widget->resize(400, 300); QVBoxLayout *layout = new QVBoxLayout; QMediaPlayer* player = new QMediaPlayer; QVideoWidget* vw = new QVideoWidget; layout->addWidget(vw); widget->setLayout(layout); player->setVideoOutput(vw); QFile file("test1.avi"); if(!file.open(QIODevice::ReadOnly)) qDebug() << "Could not open file"; player->setMedia(QUrl::fromLocalFile("test1.avi")); player->play(); widget->show(); qDebug() << player->availableMetaData() << player->currentMedia().canonicalUrl(); return app.exec();
}@
-
May be someone can share info about QMultimedia internals? I don't believe what only trustworthy info about internals we have are sources :)
-
For one question I've found information.
QMultimedia uses plugins from plugins/mediaservice folder. And to play video on Windows platform it uses Windows Media Foundation library. -
Thank you for sharing your findings on the forums.
Were you able to get the example running?
-
I run pre-compiled examples from binary distribution and made my own test basing on the logic behind. They works only on some (small amount of) videos. I really can't figure out the difference (except resolution) between two avi files with MPEG4 (H264) (one video stream and no audio streams in both) and one is played and other is not. And also I can't even get meta from files and in some cases there is no error messages at all on bad attempt.
And additionally in sources there are some more plugins (mostly for Linux) with direct show plugin. And it is not included in binary distribution.
For my own development I fall back to FFmpeg lib wrapper, cause I don't have time for now to investigate why the examples don't reliably work. -
I wondering why no one qt master quote in this thread. The questions arises by INeedMySpace are a sign of leak of information on multimedia documentation. I have the same problems but no clear documentations. So i think to use ffmpeg, but i would appreciate some answers on why qt multimedia is not quite documented and we doesn't know how backend work on different platform.
-
[quote author="INeedMySpace" date="1353418796"]I run pre-compiled examples from binary distribution and made my own test basing on the logic behind. They works only on some (small amount of) videos. I really can't figure out the difference (except resolution) between two avi files with MPEG4 (H264) (one video stream and no audio streams in both) and one is played and other is not. And also I can't even get meta from files and in some cases there is no error messages at all on bad attempt.
And additionally in sources there are some more plugins (mostly for Linux) with direct show plugin. And it is not included in binary distribution.
For my own development I fall back to FFmpeg lib wrapper, cause I don't have time for now to investigate why the examples don't reliably work.[/quote]Can you share with us this lib?
-
At this moment my Qt video player wrapper for ffmpeg is working but little bit ugly and should be improved. I could share it but need some time to organize public svn. Fill free to ask any questions here or drop me a mail - onesteptospace at google mail.
-
i have found another lib that wrap ffmpeg https://github.com/wang-bin/QtAV it seem to work fine. Maybe we can avoid to reinvent the wheel ;).