Enabling mp4/mpeg4/avc support for Qt5 WebEngine o

2020-02-29 23:33发布

问题:

i installed Qt 5.4.1 x64 on LUbuntu and created an app which uses the new QtWebEngine.

I`m trying to display a html5 page with that component which is using the tag. All works fine except if I try to playback a mp4 video. The video area remains black. It works if I use other video types like webm/ogg as source.

I know this is due to license restrictions, so that mp4 is deactivated by default in Ubuntu/Linux for Qt.

What is needed in Qt to activate it to allow mp4 playback and on what do I have pay attention in case of license terms (I read that statically linking the library is allowed?) ?

I`ve already tried to copy over the x64 distribution of libffmpegsuo.so which is included in Chrome (2,2Mb) over to the Qt directory to /plugins/webengine/ and replaced that one that was already there (1,1 Mb) but it had no effect. In Chrome playback works fine btw.

If you need more details like paths etc. please tell me.

Thanks !

回答1:

You can explicitly enable proprietary codecs (H264, MP3) when compiling Qt WebEngine:

In /path-to-qt-src-dir/qtwebengine execute:

qmake WEBENGINE_CONFIG+=use_proprietary_codecs

You should be able to see in the output that H264 codec is enabled, which is not the default configuration.