这是与此类似问题的链接:Pydub (WindowsError: [Error 2] The system can not find the file specified) 虽然在这一个中问题出在 ffmpeg 上,但我通过设置绝对路径解决了这个问题。
在为转换器和/或 ffmpeg 设置绝对路径后:
AudioSegment.converter = r'C:\ffmpeg\bin'
或
AudioSegment.ffmpeg = r'C:\ffmpeg\bin'
我仍然得到这个错误:
C:\Program Files\Python36\lib\site-packages\pydub\utils.py:193: 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) Traceback (most recent call last): File "C:/Users/Sean/Desktop/vp/encode_audio/m4a_to_wav.py", line 4, in song = AudioSegment.from_file("pines.m4a", "m4a") File "C:\Program Files\Python36\lib\site-packages\pydub\audio_segment.py", line 660, in from_file info = mediainfo_json(orig_file) File "C:\Program Files\Python36\lib\site-packages\pydub\utils.py", line 263, in mediainfo_json res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE) File "C:\Program Files\Python36\lib\subprocess.py", line 707, in init restore_signals, start_new_session) File "C:\Program Files\Python36\lib\subprocess.py", line 990, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified`
我的路径环境变量中有 ffmpeg。我的路径 envvar 中也有 libav,并按照 https://github.com/jiaaro/pydub#dependencies 中指定的顺序安装了 libav,然后安装了 pydub。 .
我所做的一切似乎都不起作用,所以任何想法或解决方案都将不胜感激!
最佳答案
我遇到了同样的问题,但我在五分钟前解决了。
解决方法如下:
(¥表示\)
我把文件放到C:\\ffmpeg\\ffmpeg\\bin\\ffmpeg.exe
(注意:这是我改文件名后的)
from pydub import AudioSegment
AudioSegment.converter = "C:\\ffmpeg\\ffmpeg\\bin\\ffmpeg.exe"
AudioSegment.ffmpeg = "C:\\ffmpeg\\ffmpeg\\bin\\ffmpeg.exe"
AudioSegment.ffprobe ="C:\\ffmpeg\\ffmpeg\\bin\\ffprobe.exe"
将这些行放在导入语句之后。
最后,重启电脑
这个问题我很苦恼,现在问题解决了。
关于python - Pydub 无法定位 ffprobe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51219531/