gpt4 book ai didi

python - Linux 上的 PyQt5 QMultimedia 出现段错误

转载 作者:行者123 更新时间:2023-12-02 09:02:16 24 4
gpt4 key购买 nike

我在 Ubuntu 18.04.3 LTS 上使用 PyQt5。我正在尝试使用 QtMultimedia.QMediaPlayer 播放 .mp3 文件。这是我的代码:

import sys

from PyQt5 import QtCore, QtMultimedia
from PyQt5.QtWidgets import QApplication, QMainWindow


class MyWidget(QMainWindow):
def __init__(self):
super().__init__()
media = QtCore.QUrl.fromLocalFile(sys.path[0] + '/sounds/banjo_A5_forte_normal.mp3')
content = QtMultimedia.QMediaContent(media)
self.player = QtMultimedia.QMediaPlayer()
self.player.setMedia(content)
self.player.play()


app = QApplication(sys.argv)
ex = MyWidget()
ex.show()
sys.exit(app.exec_())

但是当我运行它时它会收到 SIGSEGV。

当我在 PyCharm 中调试时,将断点设置为 self.player = QtMultimedia.QMediaPlayer() 并恢复程序,它可以工作,但会发出警告:

(python:12491): GStreamer-WARNING **: 17:53:39.905: Failed to load plugin '/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvaapi.so': /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvaapi.so: undefined symbol: gst_gl_display_egl_get_from_native

(python:12491): GStreamer-WARNING **: 17:53:40.030: Failed to load plugin '/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvaapi.so': /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvaapi.so: undefined symbol: gst_gl_display_egl_get_from_native

编辑:来自评论的命令。不能只发布“主要是代码”

来自ldd/usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstvaapi.so的输出:

    linux-vdso.so.1 (0x00007ffc8f5b4000)
libgstcodecparsers-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgstcodecparsers-1.0.so.0 (0x00007f1458a4b000)
libdrm.so.2 => /usr/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007f145883a000)
libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007f145861c000)
libva-drm.so.2 => /usr/lib/x86_64-linux-gnu/libva-drm.so.2 (0x00007f1458419000)
libXrandr.so.2 => /usr/lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007f145820e000)
libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f1458004000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f1457ccc000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/libGL.so.1 (0x00007f1457a40000)
libva-x11.so.2 => /usr/lib/x86_64-linux-gnu/libva-x11.so.2 (0x00007f145783a000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1457636000)
libEGL.so.1 => /usr/lib/x86_64-linux-gnu/libEGL.so.1 (0x00007f1457422000)
libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f145721e000)
libva-wayland.so.2 => /usr/lib/x86_64-linux-gnu/libva-wayland.so.2 (0x00007f1457019000)
libva.so.2 => /usr/lib/x86_64-linux-gnu/libva.so.2 (0x00007f1456df8000)
libwayland-client.so.0 => /usr/lib/x86_64-linux-gnu/libwayland-client.so.0 (0x00007f1456be9000)
libgstgl-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgstgl-1.0.so.0 (0x00007f1456983000)
libgstpbutils-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgstpbutils-1.0.so.0 (0x00007f145674b000)
libgstvideo-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgstvideo-1.0.so.0 (0x00007f14564b2000)
libgstbase-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0 (0x00007f145623d000)
libgstallocators-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgstallocators-1.0.so.0 (0x00007f1456039000)
libgstreamer-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0 (0x00007f1455cfe000)
libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f1455aaa000)
libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f1455793000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f14553f5000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f14551d6000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1454de5000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f1454bdd000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1458f6c000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f14549cb000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f14547a3000)
libGLX.so.0 => /usr/lib/x86_64-linux-gnu/libGLX.so.0 (0x00007f1454572000)
libGLdispatch.so.0 => /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007f14542bc000)
libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f14540b6000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f1453eae000)
libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007f1453cac000)
libwayland-egl.so.1 => /usr/lib/x86_64-linux-gnu/libwayland-egl.so.1 (0x00007f1453aaa000)
libgbm.so.1 => /usr/lib/x86_64-linux-gnu/libgbm.so.1 (0x00007f145389c000)
libgudev-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgudev-1.0.so.0 (0x00007f1453692000)
libgstaudio-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgstaudio-1.0.so.0 (0x00007f145341d000)
libgsttag-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgsttag-1.0.so.0 (0x00007f14531e2000)
liborc-0.4.so.0 => /usr/lib/x86_64-linux-gnu/liborc-0.4.so.0 (0x00007f1452f66000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f1452cf4000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f1452af0000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f14528ea000)
libwayland-server.so.0 => /usr/lib/x86_64-linux-gnu/libwayland-server.so.0 (0x00007f14526d7000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f14524a5000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f1452288000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f1452073000)

最佳答案

我使用以下命令在 docker(ubuntu:18.04) 中启用 Qt MultiMedia,所以我想它也应该为您服务。

sudo apt-get install -y --no-install-recommends \
libgstreamer1.0-0 \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-doc \
gstreamer1.0-tools \
libpulse-mainloop-glib0 \
alsa-base \
alsa-utils \
pulseaudio

关于python - Linux 上的 PyQt5 QMultimedia 出现段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59644444/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com