問題描述
對于我的 PyQt5 項目,我使用的是 QWebEngineView
,但某些視頻,例如 .mp4
視頻無法播放.我可以使用 pip
安裝編解碼器,或者通過 QApplication()
或類似的方式傳遞某個參數來解決此問題嗎?
For my PyQt5 project, I am using the QWebEngineView
, but certain videos, such as .mp4
videos won't play. Can I install the codecs with pip
, or pass a certain argument through QApplication()
or something similar in order to fix this problem?
我是通過pip
安裝PyQt5的,所以我沒有C:Qt...
文件,只有PyQt5
, pyqt5_tools
文件夾在 AppdataLocalProgramsPythonPython37Libsite-packages
.
I installed PyQt5 through pip
, so I don't have the C:Qt...
files, only the PyQt5
, pyqt5_tools
folders in AppdataLocalProgramsPythonPython37Libsite-packages
.
我正在使用 Python 3.7.2
和 PyQt5.11
推薦答案
pypi提供的pyqtwebengine沒有開啟use_proprietary_codecs
標志,所以無法播放.mp4.
The pyqtwebengine provided by pypi does not enable the use_proprietary_codecs
flag so you cannot play the .mp4.
如果你想獲得一個播放 mp4 的 pyqtwebengine,你必須按照以下步驟操作:
If you want to get a pyqtwebengine that plays mp4 you must follow these steps:
您必須使用
WEBENGINE_CONFIG += use_proprietary_codecs
標志編譯 Qt 以啟用播放 mp4 所需的編解碼器(Qt WebEngine功能:音視頻編解碼器)
You must compile Qt with the
WEBENGINE_CONFIG += use_proprietary_codecs
flag to enable the codecs needed to play mp4(Qt WebEngine Features: Audio and Video Codecs)
然后使用那個Qt你必須編譯pyqtwebengine.
Then using that Qt you must compile pyqtwebengine.
這篇關于使用 webengine 視頻和音頻編解碼器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!