gstreamer:没有可用于类型 'audio/x-wav' 的解码器/找不到合适的插件

gstreamer: No decoder available for type 'audio/x-wav' / no suitable plugins found

我开发了一个 Kivy Python 应用程序。它应该有声音效果。 在 Kivy 中很简单:

from kivy.core.audio import SoundLoader
...
    def btn(self):
        sound = SoundLoader.load("images/crunch.ogg")
        if sound:
            sound.play()

当这段代码运行时我得到:

[WARNING] [AudioGstplayer] b"No decoder available for type 'audio/x-wav'."
[ERROR  ] [AudioGstplayer] b'Your GStreamer installation is missing a plug-in.'
[ERROR  ] [AudioGstplayer] b'Internal data stream error.'

我了解到Kivy 使用GStreamer。所以我尝试在终端中使用它的基本实用程序来播放声音:

(base) $ gst-play-1.0 -v PycharmProjects/dima_kivy/images/crunch.wav
Press 'k' to see a list of keyboard shortcuts.
Now playing /home/slv/PycharmProjects/dima_kivy/images/crunch.wav
/GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0: ring-buffer-max-size = 0
/GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0: buffer-size = -1
/GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0: buffer-duration = -1
/GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0: use-buffering = false
/GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0: download = false
/GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0: uri = file:///home/slv/PycharmProjects/dima_kivy/images/crunch.wav
/GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0: connection-speed = 0
/GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0: source = "\(GstFileSrc\)\ source"
/GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0/GstTypeFindElement:typefind.GstPad:src: caps = audio/x-wav
WARNING No decoder available for type 'audio/x-wav'.
WARNING debug information: gsturidecodebin.c(921): unknown_type_cb (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0
ERROR Your GStreamer installation is missing a plug-in. for file:///home/slv/PycharmProjects/dima_kivy/images/crunch.wav
ERROR debug information: gsturidecodebin.c(988): no_more_pads_full (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0:
no suitable plugins found:
gstdecodebin2.c(4679): gst_decode_bin_expose (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0:
no suitable plugins found:
Missing decoder: WAV (audio/x-wav)

看来不是Kivy的问题。 我在谷歌上搜索了安装帮助的人 - 我也是:

sudo apt-get install 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 gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio

运行 这个“全部安装”命令没有任何改变。行为保持不变。 我猜是配置有误,但我什至不知道在哪里可以找到(

求求你帮忙!

我的系统:Ubuntu 20.04.1 LTS

gst-inspect-1.0 输出:

(base) slv@slv-ubuntu-comp:~$ gst-inspect-1.0 audio/x-wav
Factory Details:
  Rank                     primary (256)
  Name                     audio/x-wav
  Caps                     audio/x-wav
  Extensions               wav

Plugin Details:
  Name                     typefindfunctions
  Description              default typefind functions
  Filename                 /home/slv/miniconda3/lib/gstreamer-1.0/libgsttypefindfunctions.so
  Version                  1.14.5
  License                  LGPL
  Source module            gst-plugins-base
  Source release date      2019-05-29
  Binary package           GStreamer Base Plug-ins source release
  Origin URL               Unknown package origin

(base) slv@slv-ubuntu-comp:~$ gst-inspect-1.0 | grep wav
typefindfunctions: application/x-shockwave-flash: swf, swfl
typefindfunctions: audio/x-wav: wav
typefindfunctions: audio/x-wavpack: wv, wvp
typefindfunctions: audio/x-wavpack-correction: wvc

最后我发现,当我使用conda安装时:

conda install kivy -c conda-forge

我不小心也在 base conda 环境中创建了它,结果导致 gstreamer 的标准 Ubuntu 安装的系统路径被覆盖。 所以我通过删除该环境中的 kivy 修复了我的 base conda 环境。 现在命令 gst-play-1.0 ~/PycharmProjects/dima_kivy/images/crunch.wav 运行良好并在基础环境中产生预期的声音。

至于在我的开发环境中出现错误“gstreamer:没有可用于类型 'audio/x-wav' 的解码器/找不到合适的插件”,我已经通过安装 good 在我的开发环境中 conda-forge 的插件如下:

conda install gst-plugins-good -c conda-forge

修复了标题中提到的错误,但我的电脑仍然没有声音。 我将向 Whosebug 社区询问这个新问题的另一个问题。