Im using python 3.12.4 and pyqt6. Im trying to play back videos on websites but it will not play back and i get error failed to execute ‘addSourceBuffer’ on MediaSource’: The type provided (‘audio/mp4;codecs=”mp4a.40.2″‘) is unsupported. I cannot figure out why it is doing this.
import sys
import os
from PyQt6.QtCore import QUrl
from PyQt6.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget
from PyQt6.QtWebEngineWidgets import QWebEngineView
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("DRM Test")
self.setGeometry(100, 100, 1280, 720)
layout = QVBoxLayout()
browser = QWebEngineView()
browser.setUrl(QUrl("https://www.theoplayer.com/theoplayer-drm-aes-128-encryption"))
layout.addWidget(browser)
container = QWidget()
container.setLayout(layout)
self.setCentralWidget(container)
if __name__ == '__main__':
# Set the Widevine CDM path (adjust the path to your actual Widevine CDM location)
widevine_cdm_path = r"C:Program Files (x86)MicrosoftEdgeWebViewApplication127.0.2651.86WidevineCdm_platform_specificwin_x64widevinecdm.dll"
os.environ['QTWEBENGINE_CHROMIUM_FLAGS'] = f'--widevine-cdm-path="{widevine_cdm_path}"'
# Enable proprietary codecs and other necessary features
os.environ['QTWEBENGINE_CHROMIUM_FLAGS'] += ' --enable-logging --v=1 --enable-widevine-cdm --enable-features=WebRTCH264Codec,MediaSource,WebAudio --ignore-gpu-blacklist --disable-gpu-sandbox --disable-software-rasterizer --disable-accelerated-video-decode --disable-accelerated-video-encode'
app = QApplication(sys.argv)
main_window = MainWindow()
main_window.show()
sys.exit(app.exec())
New contributor
Sam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.