Switch QMultiMedia backend without recompiling whole Qt



  • Hello,

    I am currently working on an mp3 player and I would like use the WMF (Windows Media Foundation) backend for QMultiMedia (instead of DirectShow). I know there is the option -mediaplayer-backend wmf to recompile Qt as a whole but I'd like to just recompile QMultiMedia.

    Is there a way a achieve this?

    I am using Qt 5.10.1 and Visual Studio 15 2017 64bit as a compiler.



  • To expand my question I'd like to add that the reason I just want to compile QMultiMedia is that building the whole Qt library fails. Here are the steps I did:

    1. Download the Qt sources into the directory C:/Qt/5.10.1/Src.
    2. Install ActivePerl.
    3. Python 3 is already installed (or does it have to be Python 2?).
    4. Add qtbase/bin and gnuwin32/bin to path.
    5. Open CMD with admin privileges and call vsdevcmd.bat to setup Visual Studio environment.
    6. Configure with configure -platform win32-msvc -debug-and-release -mediaplayer-backend wmf
    7. Let it run, it performs checks and every seems to be ok.
    8. Call jom to build.
    9. Now qmake.exe crashes for some reason and it end with the following error:

    jom: C:\Qt\5.10.1\Src\qtbase\src\Makefile [sub-corelib-make_first] Error 2
    jom: C:\Qt\5.10.1\Src\qtbase\Makefile [sub-src-make_first] Error 2
    jom: C:\Qt\5.10.1\Src\Makefile [module-qtbase-make_first] Error 2


  • Qt Champions 2017

    @jsmolka said in Switch QMultiMedia backend without recompiling whole Qt:

    Python 3 is already installed (or does it have to be Python 2?).

    The docs are a bit unclear here, but they recommend Python 2.7 for Windows. May be worth a try.

    I have done some developer builds on Windows (with Python 2.7.14) and encountered all kinds of problems, but never saw a crashing qmake.

    Regards


  • Lifetime Qt Champion

    Hi,

    IIRC, the MSVC edition comes with both backends. What you can do is temporarily move the DirectX backend in another folder to see if that does what you want.

    Otherwise, you don't need to build all of Qt, just the qtmultmedia module.



  • This post is deleted!


  • @SGaist I have read something simular and compared to the MinGW version the MSVC version comes with precompiled binaries in the form of wmfengine.dll under plugins/mediaservice. But if I remove the dsengine.dll files I get the following console output when starting my application: defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer".

    Am I removing the wrong files?

    Apart from that I have successfully compiled the previous Qt version (5.10.0) with the -mediaplayer-backend wmf option. This does not seem to have any effect though because I am still getting DirectShow errors for mp3s with large cover files.


  • Lifetime Qt Champion

    No, you removed the correct file, however that confirms that the WMF plugin wasn't built with media player capabilities.

    Then do the same you just did with your 5.10.0 custom version to see if it behaves better.



  • @SGaist My custom version behaves completely odd. I can literally remove the whole plugins/mediaservice folder and my application is still running and throwing DirectShow errors. I double checked the path for the DLLs and it definitely uses my compiled version.

    I probably made some mistake somewhere along the line but I can't figure out where. I'd really like to use QMultiMedia but the DirectShow backend is destroying it for me. If you have any suggestion for a different configuration and something else I would really appreciate it.


  • Lifetime Qt Champion

    Then some maybe silly questions:

    • Did you deploy the plugins along your application ?
    • Are you sure that you are using the right kit ?
    • In the Kit, are you sure you are using your custom version of Qt ?


  • @SGaist I am using Qt Creator to build my application and I don't deploy anything beside it at the moment. The path to the DLLs is set in the path environment variable. I made sure that my custom version if being used.



  • Just download the QtMM sources and compile/install it. And then just remove the 'ds' backend if you do not need in (and keep only the 'wmf' backend).



  • @kuzulis

    @SGaist I have read something simular and compared to the MinGW version the MSVC version comes with precompiled binaries in the form of wmfengine.dll under plugins/mediaservice. But if I remove the dsengine.dll files I get the following console output when starting my application: defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer".

    Isn't this what you mean?



  • Yes, that.

    It is strange that this error:

    no service found for - "org.qt-project.qt.mediaplayer"

    occurred.

    As I can see from QtMM sources:

    MFPlayerService::MFPlayerService(QObject *parent)
        : QMediaService(parent)
        , m_session(0)
        , m_videoWindowControl(0)
        , m_videoRendererControl(0)
    {
        m_audioEndpointControl = new MFAudioEndpointControl(this);
        m_session = new MFPlayerSession(this);
        m_player = new MFPlayerControl(m_session);
        m_metaDataControl = new MFMetaDataControl(this);
    } 
    
    QMediaControl* MFPlayerService::requestControl(const char *name)
    {
        if (qstrcmp(name, QMediaPlayerControl_iid) == 0) {
            return m_player;
    

    }

    And the wmf.json contains:

    {
        "Keys": ["windowsmediafoundation"],
        "Services": ["org.qt-project.qt.mediaplayer", "org.qt-project.qt.audiodecode"]
    } 
    

    so, all should be fine.



  • @kuzulis
    @jsmolka
    @SGaist

    However, the service(org.qt-project.qt.mediaplayer) is missing in Qt5.9.* / Qt5.10.* dll. Please check with the following command and let us know the results.

    like this:
    QtPluginInfo.exe wnfengine.dll

    The solution I know must fix the Qt5.10 source. But this is not the official way. I guess it is a bug. The Qt5.7 version has no problem.



  • Yes, you can try to report it as a bug.



  • @kuzulis
    @Devopia53
    @SGaist

    So after some time I got it to work. The solution is just using -mediaplayer-backend wmf as an configure option and then compiling Qt. The reason why I got no error for removing the all files within the plugin folder was that Qt Creator was still using the precompiled binaries even though there was no path set to them. In the end @SGaist was right and asked the right question regarding using the wrong kit.

    The only thing that still confuses me is qmake crashing while compiling Qt 5.10.1. If I try to compile Qt 5.10.0 everything works just fine. Here are the step I did for compiling (if anybody stumbles across the same problem):

    1. Download the lastest Qt sources
    2. Install jom, Python and Perl
    3. Open cmd and setup your VS environment (with vcvars32.bat, vcvars64 or vsdevenv.bat)
    4. Configure Qt using configure -debug-and-release -platform win32-msvc -nomake examples -opensource -prefix <insert your install dir> -mediaplayer-backend wmf
    5. Run jom and later jom install

    Using the WMF backend seems to be much better for playing mp3s because DirectShow is unable to play files with covers above 100kb and gets the song duration wrong by around 2sec everytime (but it also plays those extra seconds and seems to "expand" the mp3).

    Thank you guys.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.