Linux Qt5.15.2 compile le code source de QWebEngine pour prendre en charge l'audio et la vidéo H264

arrière-plan

Le QWebEngine intégré par défaut ne prend pas en charge les fonctions audio et vidéo en raison de problèmes de droits d'auteur, et vous devez compiler vous-même le code source pour le prendre en charge.

Plateforme : Linux (UOS V20 1050)
Qt : 5.15.2

Préparation

  1. Téléchargez le code source correspondant à Qt 5.15.2, utilisez le site miroir ou l'outil Qt Maintenance Tool pour télécharger.
  2. Configurer les variables d'environnement Qt
vim ~/.bashrc

Ajoutez le contenu suivant au fichier bashrc

#QT ENV
export PATH=/home/Leou/Qt/5.15.2/gcc_64/bin:$PATH
export LD_LIBRARY_PATH=/home/Leou/Qt/5.15.2/gcc_64/lib:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=/home/Leou/Qt/5.15.2/gcc_64/plugins:$QT_PLUGIN_PATH
export QML2_PATH=/home/Leou/Qt/5.15.2/gcc_64/qml:$QML2_PATH

Actualiser pour prendre effet

source ~/.bashrc

Les bibliothèques requises peuvent être préinstallées à ce stade :

Sur toutes les plateformes, les outils suivants sont requis au moment de la construction :

  • Python 2.7.5 ou version ultérieure. Python 3 n'est pas pris en charge.
  • Bison, Flex
  • GPerf
  • Node.js version 8 ou ultérieure (la version 12 ou ultérieure est recommandée)

Ce sont les exigences les plus élémentaires. En fait, de nombreuses bibliothèques doivent être installées. Veuillez vous référer à qtwebengine-platform-notes

compiler

Créez le répertoire de build et utilisez qmake ../qtwebengine.pro -- -webengine-proprietary-codecsla commande

Leou@Leou-PC:/media/Leou/qtwebengine$ mkdir build
Leou@Leou-PC:/media/Leou/qtwebengine$ cd build/
Leou@Leou-PC:/media/Leou/qtwebengine/build$ qmake ../qtwebengine.pro -- -webengine-proprietary-codecs

Informations de sortie :

Info: creating stash file /media/Leou/qtwebengine/build/.qmake.stash
Info: creating cache file /media/Leou/qtwebengine/build/.qmake.cache

Running configuration tests...
Checking for architecture supported... yes
Checking for bison... no
Checking for submodule initialized... yes
Checking for build path without whitespace... yes
Checking for platform supported... 
Checking for gperf... yes
Checking for flex... no
Checking for host pkg-config... /usr/bin/pkg-config
Checking for jumbo build merge limit... 8
Checking for linker supports -z noexecstack... yes
Checking for x11... yes
Checking for libdrm... yes
Checking for xcomposite... yes
Checking for xcursor... yes
Checking for xi... yes
Checking for xtst... yes
Checking for python2... /usr/bin/python2
Checking for d-bus... yes
Checking for fontconfig... yes
Checking for freetype >= 2.4.2... yes
Checking for glib-2.0 >= 2.32.0... yes
Checking for glibc > 2.16... yes
Checking for jsoncpp... no
Checking for khr... yes
Checking for lcms2... no
Checking for libevent... no
Checking for libvpx... no
Checking for libwebp, libwebpmux and libwebpdemux... no
Checking for compatible libxml2 and libxslt... no
Checking for minizip... no
Checking for system ninja... no
Checking for nss >= 3.26... yes
Checking for opus... no
Checking for protobuf... no
Checking for re2... no
Checking for snappy... no
Checking for zlib... yes
Done running configuration tests.

Configure summary:

Qt WebEngine Build Tools:
  Use System Ninja ....................... no
  Use System Gn .......................... no
  Jumbo Build Merge Limit ................ 8
  Developer build ........................ no
  Sanitizer .............................. no
  QtWebEngine required system libraries:
    fontconfig ........................... yes
    dbus ................................. yes
    nss .................................. yes
    khr .................................. yes
    glibc ................................ yes
  QtWebEngine required system libraries for qpa-xcb:
    x11 .................................. yes
    libdrm ............................... yes
    xcomposite ........................... yes
    xcursor .............................. yes
    xi ................................... yes
    xtst ................................. yes
  Optional system libraries used:
    re2 .................................. no
    icu .................................. no
    libwebp, libwebpmux and libwebpdemux . no
    opus ................................. no
    ffmpeg ............................... no
    libvpx ............................... no
    snappy ............................... no
    glib ................................. yes
    zlib ................................. yes
    minizip .............................. no
    libevent ............................. no
    jsoncpp .............................. no
    protobuf ............................. no
    libxml2 and libxslt .................. no
    lcms2 ................................ no
    png .................................. no
    JPEG ................................. no
    harfbuzz ............................. no
    freetype ............................. yes

Note: The following modules are not being compiled in this configuration:
    webenginecore
    webengine
    webenginewidgets
    pdf
    pdfwidgets

WARNING: Tool bison is required to build QtWebEngine.

WARNING: Tool bison is required to build QtPdf.

WARNING: QtWebEngine will not be built.

WARNING: QtPdf will not be built.

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into '/home/Leou/Qt/5.15.2/gcc_64'.

Prior to reconfiguration, make sure you remove any leftovers from
the previous build.

Affichez le résultat et installez les bibliothèques manquantes :

Installer des bisons

sudo apt install bison

Installer la flexibilité

sudo apt install flex

Après l'installation, on soupçonne qu'il existe un cache, il n'est donc pas mis à jour. Vous pouvez supprimer le produit en cours de construction et l'exécuter à nouveau.qmake ../qtwebengine.pro -- -webengine-proprietary-codecs

Informations de sortie :

Leou@Leou-PC:/media/Leou/QtSrc/Src/qtwebengine/build$ qmake ../qtwebengine.pro -- -webengine-proprietary-codecs

Running configuration tests...
Done running configuration tests.

Configure summary:

Qt WebEngine Build Tools:
  Use System Ninja ....................... no
  Use System Gn .......................... no
  Jumbo Build Merge Limit ................ 8
  Developer build ........................ no
  Sanitizer .............................. no
  QtWebEngine required system libraries:
    fontconfig ........................... yes
    dbus ................................. yes
    nss .................................. yes
    khr .................................. yes
    glibc ................................ yes
  QtWebEngine required system libraries for qpa-xcb:
    x11 .................................. yes
    libdrm ............................... yes
    xcomposite ........................... yes
    xcursor .............................. yes
    xi ................................... yes
    xtst ................................. yes
  Optional system libraries used:
    re2 .................................. no
    icu .................................. no
    libwebp, libwebpmux and libwebpdemux . no
    opus ................................. no
    ffmpeg ............................... no
    libvpx ............................... no
    snappy ............................... no
    glib ................................. yes
    zlib ................................. yes
    minizip .............................. no
    libevent ............................. no
    jsoncpp .............................. no
    protobuf ............................. no
    libxml2 and libxslt .................. no
    lcms2 ................................ no
    png .................................. no
    JPEG ................................. no
    harfbuzz ............................. no
    freetype ............................. yes
Qt WebEngineCore:
  Embedded build ......................... no
  Full debug information ................. no
  Pepper Plugins ......................... yes
  Printing and PDF ....................... yes
  Proprietary Codecs ..................... yes
  Spellchecker ........................... yes
  Native Spellchecker .................... no
  WebRTC ................................. yes
  PipeWire over GIO ...................... no
  Geolocation ............................ yes
  WebChannel support ..................... yes
  Kerberos Authentication ................ no
  Extensions ............................. yes
  Node.js ................................ no
  Support qpa-xcb ........................ yes
  Use ALSA ............................... yes
  Use PulseAudio ......................... yes
Qt WebEngineQml:
  Support Qt WebEngine Qml ............... yes
  UI Delegates ........................... yes
  Test Support ........................... no
Qt WebEngineWidgets:
  Support Qt WebEngine Widgets ........... yes
Qt PDF:
  Support V8 ............................. no
  Support XFA ............................ no
  Support XFA-BMP ........................ no
  Support XFA-GIF ........................ no
  Support XFA-PNG ........................ no
  Support XFA-TIFF ....................... no
Qt PDF Widgets:
  Support Qt PDF Widgets ................. yes

WARNING: Building without node.js will disable some features of QtWebEngine DevTools.

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into '/home/Leou/Qt/5.15.2/gcc_64'.

Prior to reconfiguration, make sure you remove any leftovers from
the previous build.

Exécuter la création

make -j14

Si une erreur se produit, exécutez la commande make plusieurs fois de plus
Insérer la description de l'image ici

Après exécution :

mv -f libqwebengineview.so ../../../plugins/designer/libqwebengineview.so
objcopy --only-keep-debug ../../../plugins/designer/libqwebengineview.so ../../../plugins/designer/libqwebengineview.so.debug && objcopy --strip-debug ../../../plugins/designer/libqwebengineview.so && objcopy --add-gnu-debuglink=../../../plugins/designer/libqwebengineview.so.debug ../../../plugins/designer/libqwebengineview.so && chmod -x ../../../plugins/designer/libqwebengineview.so.debug
make[3]: 离开目录“/media/Leou/QtSrc/Src/qtwebengine/build/src/plugins/qwebengineview”
make[2]: 离开目录“/media/Leou/QtSrc/Src/qtwebengine/build/src/plugins”
rm -f libQt5PdfWidgets.so.5.15.2 libQt5PdfWidgets.so libQt5PdfWidgets.so.5 libQt5PdfWidgets.so.5.15
g++ -Wl,--no-undefined -Wl,--version-script,QtPdfWidgets.version -Wl,--enable-new-dtags -Wl,-z,origin -Wl,-rpath,\$ORIGIN -Wl,-rpath,\$ORIGIN -Wl,-rpath-link,/home/Leou/Qt/5.15.2/gcc_64/lib -shared -Wl,-Bsymbolic-functions -Wl,-soname,libQt5PdfWidgets.so.5 -o libQt5PdfWidgets.so.5.15.2 .obj/qpdfview.o  -L/home/qt/openssl-1.1.1g/lib /media/Leou/QtSrc/Src/qtwebengine/build/lib/libQt5Pdf.so /home/Leou/Qt/5.15.2/gcc_64/lib/libQt5Widgets.so /home/Leou/Qt/5.15.2/gcc_64/lib/libQt5Gui.so /home/Leou/Qt/5.15.2/gcc_64/lib/libQt5Core.so -lpthread -lGL   
ln -s libQt5PdfWidgets.so.5.15.2 libQt5PdfWidgets.so
ln -s libQt5PdfWidgets.so.5.15.2 libQt5PdfWidgets.so.5
ln -s libQt5PdfWidgets.so.5.15.2 libQt5PdfWidgets.so.5.15
rm -f ../../lib/libQt5PdfWidgets.so.5.15.2
mv -f libQt5PdfWidgets.so.5.15.2 ../../lib/libQt5PdfWidgets.so.5.15.2
rm -f ../../lib/libQt5PdfWidgets.so
rm -f ../../lib/libQt5PdfWidgets.so.5
rm -f ../../lib/libQt5PdfWidgets.so.5.15
mv -f libQt5PdfWidgets.so ../../lib/libQt5PdfWidgets.so
mv -f libQt5PdfWidgets.so.5 ../../lib/libQt5PdfWidgets.so.5
mv -f libQt5PdfWidgets.so.5.15 ../../lib/libQt5PdfWidgets.so.5.15
objcopy --only-keep-debug ../../lib/libQt5PdfWidgets.so.5.15.2 ../../lib/libQt5PdfWidgets.so.5.15.2.debug && objcopy --strip-debug ../../lib/libQt5PdfWidgets.so.5.15.2 && objcopy --add-gnu-debuglink=../../lib/libQt5PdfWidgets.so.5.15.2.debug ../../lib/libQt5PdfWidgets.so.5.15.2 && chmod -x ../../lib/libQt5PdfWidgets.so.5.15.2.debug
make[2]: 离开目录“/media/Leou/QtSrc/Src/qtwebengine/build/src/pdfwidgets”
make[1]: 离开目录“/media/Leou/QtSrc/Src/qtwebengine/build/src”

Vous pouvez voir les produits sous lib
Insérer la description de l'image ici

Installer

Remplacez directement le QWebEngine qui installe actuellement Qt

make install

test

Utilisez le programme de démonstration simplebrowser de Qt pour ouvrir le site Web html5test afin de tester la fonction :
Insérer la description de l'image ici
on peut voir que les fonctions audio et vidéo telles que h264 et mp3 sont déjà prises en charge.

Résumer

La compilation de QWebEngine sous Linux est généralement plus simple et pas aussi difficile que la compilation de Chrome.

https://doc.qt.io/qt-5/qtwebengine-platform-notes.html

Guess you like

Origin blog.csdn.net/no_say_you_know/article/details/133179189