微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将 FFMPEG 添加到 macOS 路径以在 Python 中将 mp3 转换为 WAV 的问题

如何解决将 FFMPEG 添加到 macOS 路径以在 Python 中将 mp3 转换为 WAV 的问题

我正在尝试使用一个简单的程序在 python 中将 .MP3 文件转换为 .WAV 文件

from os import path
from pydub import AudioSegment

src = "test1.mp3"
dst = "test1.wav"

# convert wav to mp3                                                            
sound = AudioSegment.from_mp3(src)
sound.export(dst,format="wav")

当我尝试在 IDE 中运行程序时,我收到 FileNotFoundError 这就是 StackTrace 的样子:

RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe,but may not work
  warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe,but may not work",RuntimeWarning)

...

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

我知道这个错误意味着 IDE 无法找到我的 FFMPEG(因为它不在正确的路径中)。我下载了 FFMPEG,FFPROBE 位于 FFMPEG 库中,使用:

pip install FFMPEG

但是,即使我尝试使用

从命令行运行程序
python soundtest.py

我收到另一个 FileNotFoundError:

File "soundtest.py",line 13,in <module>
    with open('simple.html') as html_file:
FileNotFoundError: [Errno 2] No such file or directory: 'simple.html'

我不确定为什么会发生这种情况,因为尽管 FFMPEG 位于 IDE 访问的正确路径中,但我也无法从命令行运行它。

理想情况下,我想将 FFMPEG 库添加到系统路径中,以便可以访问它,但我什至无法从命令行运行它。知道这里发生了什么吗?

此处提供的答案也有助于提供更多见解,但我仍然遇到同样的错误Ffmpeg on idle python Mac

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。