PDA

View Full Version : Not able to play Videos with QMediaPlayer and QVideoWiget in Qt 5.2



sky
30th January 2014, 13:56
Hi,

I have been trying to play video formats *.wmv, *.mp4 with QMediaPlayer and QVideoWidget in Qt5.2. I just followed the expample and here is my code:



mp =new QMediaPlayer(this);
vw = new QVideoWidget(this);
QMediaPlaylist* playlist = new QMediaPlaylist(this);
playlist->addMedia(QUrl::fromLocalFile("C:/Users/Public/Videos/Sample Videos/Wildlife.wmv"));
playlist->setCurrentIndex(1);
mp->setPlaylist(playlist);
mp->setVideoOutput(vw);
setGeometry(100,100,400,500);
vw->setGeometry(0,0,300,400);
show();
play();


I have installed the K-Lite codecs. When I play the same files using Media Player Classic or Win Media Player the files play well and the the Lca and FFmpeg icons show up in the tray.

But with Qt 5.2 I am not able to see any visuals for any video file. Only for wmv files I am able to hear audio(no visual).

I have searched a lot on the web and everybody points to codecs which I believe I have. Does the configuration of the K-Lite codecs matter? I have used the default codecs. I have built Qt with the Win media foundation too. So I am at a loss to understand what is wrong here. Platform is win7 32.
Any help is appreciated. Do let me know if I have to reading anything or any article or blog. Thank you.

budda
30th January 2014, 16:03
The question is what compiler with Qt 5.2.1 are you using? Opening just .AVI video? you're using MinGW. Opening other formats, use VS2012.
I have mine doing .MOV, .AVI, .MP4 working with VS2012 64 bit and 32 bit. While .AVI working with MinGW.
think your issue is that the VS2012 and VS2010 have DirectX Support, while I believe that MinGW doesn't.
Have to say out of the box video without Phonon manual configuring is nice.
oh I use Qt 5.2.0 Windows 8.1 haven't tried it in Ubuntu or Mac land yet

sky
30th January 2014, 16:46
Hi Budda,

Thanks for the reply.
The compiler is MSVC++ 2010. I have been using the same platform, same compiler, codecs with 4.8.5. And it works all well.
Now I am trying to move to Qt5.2. And I am facing this problem. The problem is with all formats. Only with wmv files I am able to hear the audio.

Sky.

budda
30th January 2014, 17:12
off hand, I'd say that to install it in with 4.8 you did all the extra stuff like DirectX SDK and such. I have my 4.8 on a virtual machine, so my Qt5.2 install is fresh on my current OS and my VS is Pro not Express.
So it might be a VS2010 issue or a combined VS2010 with DirectX SDK issue. I would install 5.2 on another machine or in it's own virtual machine.... virtual box is free.. I do have sound working in 5.2 with VS2012 wouldn't think VS2010 wouldn't be supported...

Added after 7 minutes:

sadly though, I should mention that sound isn't supported in virtual box and every time it tries to play anything, you get a pop up message saying that the pins arent' connected... I use my virtual machine in 4.8 for development only and then move the software to another machine for useage.

Added after 4 minutes:

Plus don't you have environment variables for DirectX SDK for Qt4.8 ? Maybe this is in conflict with 5.2 install... I would seriously install on an OS that doesn't have an older version of Qt on it. Especially one that has Phonon configured on it.

sky
31st January 2014, 06:52
Hi Budda,

I do not think this has got anything to do with the MSVC compilers. I just hope somebody who has faced a similarly problem to post their solution.

Sky.

budda
1st February 2014, 03:04
I'm just saying that you are trying to install 5.2 when that OS is set up for 4.8 most likely Phonon and phonon-backend configuration. Plus to properly install that (4.8) you had to have VS Pro version of 2010 or 2008 (it will build but not work with Express)... And then the DirectX SDK and the VS SDK update patch for Qt. Installing Qt 5.2 on a fresh OS, and it does video out of the box after install. Plus video codex of course. If you're having that bad of problems playing video files & sound with 5.2 installed on a previous and current 4.8 install, the 4.8 install might be the issue with the 5.2 Put 5.2 on a laptop or another machine and see if you still have sound/playback issues.

Added after 28 minutes:

so your 4.8 phonon-backend video playback sink is installed on that machine through the DirectX and specified as the video sink, installing Qt 5.2 which doesn't use phonon or phonon-backend DirectX configuration would cause serious problems if it was trying to call a video playback sink.... Phonon did audio through the read/write file I/O so that's probably why it works with just .WMV or works at all. I'm sure 5.2 still uses DirectX in some way and the 4.8 install is still taking precedence since there's like a bunch of environment path items for 4.8 (C:\Program Files\Microsoft DirectX SDK (June 2010);C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin; for example) plus the DXSDK_DIR variable itself , so it is trying to use the 4.8 phonon-backend sinks and therefore no video playback. Since 4.8 is kinda a pain to set up for phonon, don't uninstall it... i would again just install 5.2 on a fresh OS.

sky
5th February 2014, 13:54
Hi All,

I changed the video card to Nvidia GeForce 210 which supports OpenGL 3.3. My previous one supported only OpenGl 1.1. Qt5 on windows needs cards that support OpenGL 2.1 or greater. Now I am able to play all wmv videos properly but for any other format I get the following error: DirectShowPlayerService::doRender: Unresolved error code 80040266. VFW_E_NO_TRANSPORT Pins cannot connect because they don't support the same transport. For example, the upstream filter might require the IAsyncReader interface, while the downstream filter requires IMemInputPin. Do I have to build directshow or Qt5 after changing the video card?

Added after 35 minutes:

Hi All,

It was the video card. It needed a video card that supports OpenGL Version 2.1 or more. Once I upgraded the video card to GeForce 210 which supports OpenGL 3.3 and installed the default K-Lite Codecs I was able to play all videos and audio.

Sky.