Unsolved How to switch mediaservice backend to wmf ?
-
I'm building an mp3 player and noticed that Qmediaplayer reports wrong duration(), I'm on Windows 10 and would like to switch the mediaservice backend (which is Direct Show by default) to Windows Media Foundation in order to see if it solves the duration problem. How can I do that ?
I have read this Qt Documentation on the matter, but it does not provide clear instructions.
-
If you are using MinGW versions there's no wmf support.
-
@Bonnie I'm using PyQt, do you know whether wmf is supported in my case ?
-
@MrKartofel
Sorry, I don't know.
But in C++ Qt, if wmf is supported (MSVC versions), it is actually the default backend of mediaservice.
[Edited] I've tested in MSVC 5.15, the above I thought seems not true.
I don't know the structure of PyQt, does it have "mediaservice" plugin folder with dlls?
MinGW versions (wmf not supported) will only have "dsengine.dll", while MSVC versions (wmf supported) will have both "dsengine.dll" and "wmfengine.dll".
If wmf is supported, the link you posted above already tells how to make it default: set the enviroment variableQT_MULTIMEDIA_PREFERRED_PLUGINS
towindowsmediafoundation
.
If it has no effect, then I think wmf is not supported in that case. -
@Bonnie Yes with PyQt there is a mediaservice plugin folder with both the "dsengine.dll" and "wmfengine.dll" (as well as "qtmedia_audioengine.dll"). I tried changing setting the QT_MULTIMEDIA_PREFERRED_PLUGINS environment variable to windowsmediafoundation using os.environ, but it has no effect. I don't understand why, especially since the "wmfengine.dll" is indeed present in the mediaservice folder.
I know that it has no effect because trying to delete the dsengine.dll while running my music player app results in an error because dsengine.dll is "being used by Python". wmfengine.dll on the other hand, can be deleted without such error.
It is too bad I can't change the plugin because DirectShow is really messing up the musicplayer, when I load files with "unusual" bitrates (e.g. 241 kbits/s), the duration is completely off, and using a time slider to move through the song will result in even worse duration bugs. But when I load files with "typical" bitrates (e.g. 128 kbits/s) it works flawlessly.
-
@MrKartofel said in How to switch mediaservice backend to wmf ?:
there is a mediaservice plugin folder with both the "dsengine.dll" and "wmfengine.dll"
What happens if you remove dsengine.dll?
-
@JKSH When I remove dsengine.dll from the mediaservice folder, I get the following warning :
defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"
And when I try to play a music, nothing happens.
-
@MrKartofel
One possible explanation is that your wmf plugin may be not loaded properly.
Try to run the app with settingQT_DEBUG_PLUGINS
environment variable to1
and check the output.
Not sure what kind of output would PyQt get though.... -
@Bonnie So I ran the app with the QT_DEBUG_PLUGINS environment variable set to 1, I got the following output (I only copied the part where it gets to the mediaservice folder) :
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/ MyUsername /miniconda3/envs/jdr/Library/plugins/mediaservice" ... QFactoryLoader::QFactoryLoader() looking at "C:/Users/ MyUsername /miniconda3/envs/jdr/Library/plugins/mediaservice/dsengine.dll" Found metadata in lib C:/Users/ MyUsername /miniconda3/envs/jdr/Library/plugins/mediaservice/dsengine.dll, metadata= { "IID": "org.qt-project.qt.mediaserviceproviderfactory/5.0", "MetaData": { "Keys": [ "directshow" ], "Services": [ "org.qt-project.qt.camera", "org.qt-project.qt.mediaplayer" ] }, "className": "DSServicePlugin", "debug": false, "version": 329991 } Got keys from plugin meta data ("directshow") QFactoryLoader::QFactoryLoader() looking at "C:/Users/ MyUsername /miniconda3/envs/jdr/Library/plugins/mediaservice/qtmedia_audioengine.dll" Found metadata in lib C:/Users/ MyUsername /miniconda3/envs/jdr/Library/plugins/mediaservice/qtmedia_audioengine.dll, metadata= { "IID": "org.qt-project.qt.mediaserviceproviderfactory/5.0", "MetaData": { "Keys": [ "audiocapture" ], "Services": [ "org.qt-project.qt.audiosource" ] }, "className": "AudioCaptureServicePlugin", "debug": false, "version": 329991 } Got keys from plugin meta data ("audiocapture") QFactoryLoader::QFactoryLoader() looking at "C:/Users/ MyUsername /miniconda3/envs/jdr/Library/plugins/mediaservice/wmfengine.dll" Found metadata in lib C:/Users/ MyUsername /miniconda3/envs/jdr/Library/plugins/mediaservice/wmfengine.dll, metadata= { "IID": "org.qt-project.qt.mediaserviceproviderfactory/5.0", "MetaData": { "Keys": [ "windowsmediafoundation" ], "Services": [ "org.qt-project.qt.audiodecode" ] }, "className": "WMFServicePlugin", "debug": false, "version": 329991 } Got keys from plugin meta data ("windowsmediafoundation") QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/MyUsername/miniconda3/envs/jdr/mediaservice" ... loaded library "C:/Users/ MyUsername /miniconda3/envs/jdr/Library/plugins/mediaservice/dsengine.dll"
I also checked it with the QT_MULTIMEDIA_PREFERRED_PLUGINS environment variable set to windowsmediafoundation, but it does not seem to affect the debug output.
I appreciate your help, I don't know if you can do something with the output.
-
@MrKartofel
From your output, the wmfengine only provides "org.qt-project.qt.audiodecode" service, no "org.qt-project.qt.mediaplayer".
That's different from MSVC versions.
So I think it can't be used as a QMediaPlayer backend.