问题描述
我在Windows和Linux上运行的Pydub模块有问题.当我尝试这样打开mp3文件时:
I have a problem with Pydub module running in Windows and Linux. When I try open a mp3 file thus:
from pydub import AudioSegment
sound = AudioSegment.from_mp3("test.mp3")
控制台向我显示下一条消息:
Console show me the next message:
但是...我将文件(test.mp3)与脚本保存在同一文件夹中,名称正确.
But...I have the file (test.mp3) in the same folder that the script, the name is correct.
为什么我有这个问题? (在Linux中,具有相同的错误)
Why I have this problem? (In Linux, have the same error)
推荐答案
请确保您具有ffmpeg
http://www.ffmpeg.org/已安装.您可以从此官方页面获得帮助.
Make sure that you have ffmpeg
http://www.ffmpeg.org/ installed. You can get help from this official page.
我能想到的另一件事是ffmpeg
已安装并且在您的路径中,但不在使用pydub
的进程的路径中.
Other thing that I can think of is that ffmpeg
is installed and is in your path but not in the path of the process using pydub
.
如果这是错误的原因,则可以直接将绝对路径设置为ffmpeg
,如下所示:
If this is the reason for the error, then you can set the absolute path to ffmpeg
directly like shown below:
import pydub
pydub.AudioSegment.ffmpeg = "/absolute/path/to/ffmpeg"
sound = AudioSegment.from_mp3("test.mp3")
尝试一下.
这篇关于Pydub(WindowsError:[错误2]系统找不到指定的文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!