python - 找不到文件错误 : [Errno 2] No such file or directory: 'ffprobe' : 'ffprobe'

标签 python pydub

运行代码片段时,出现标题中的错误。

我已经重新安装了软件包pydub,以及pip3 install ffprobe

    from pydub.playback import play
    from pydub import AudioSegment


    def change_volume(file_name, alteration):

        song = AudioSegment.from_mp3(file_name)

        new_song = song + alteration

        new_title = ("_%s") % (file_name)

        new_song.export(new_title, format='mp3')

    change_volume("test_sample.mp3", 3)

代码的输出应该是目录中的一个新的 mp3 文件,音量水平略有提高 (test.mp3 --> _test.mp3),而不是我得到错误:

FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe': 'ffprobe'

最佳答案

首先确保你安装了ffprobe,它是FFmpeg的一部分,所以实际上你需要安装ffmpeg。您可以按照这两个站点之一的说明进行操作。

https://ffmpeg.org/download.html

https://github.com/adaptlearning/adapt_authoring/wiki/Installing-FFmpeg

之后,您需要将库添加到您的系统路径中,以便 python 能够找到并使用它。这可以通过将 FFmpeg 的安装路径实际添加到您的操作系统路径(如何操作取决于您的操作系统),或通过将其添加到 python 内部使用的临时路径变量来完成。

import sys
sys.path.append('/path/to/ffmpeg')

对于第二个选项,您必须确保在导入任何其他内容之前将路径附加到 FFmpeg。如果您没有更改根系统配置的选项,这是更好的选择,但当被不同的 python 脚本使用时会变得非常不一致。

最后确保安装了 ffprobe(例如,在终端中使用 pip install ffprobe,参见 https://pypi.org/project/ffprobe)以便 import ffprobe应该在 python 环境中工作。

关于python - 找不到文件错误 : [Errno 2] No such file or directory: 'ffprobe' : 'ffprobe' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57350259/

相关文章:

audio - 如何在 Python 中将 4 声道立体声文件转换为单声道

Python - 从另一个函数中的函数检索值,而不重新运行原始函数

python - 无需共享数据的快速/简单数组比较算法

python - 在 python 中构造 janusgraph 的 get 查询

python - 如何将单个音频文件拆分为多个文件?

python - 为什么 python 找不到我的文件?

audio - Pydub恢复覆盖音频文件

java - 使用 Chaquopy 在 Android 中自写 python 代码

python - TypeError : a bytes-like object is required, 不是 'str' - hmac

python - 为什么人们说python很慢是因为它被解释了?它有 .pyc 文件