我在python里使用了 pydub 库。处理音频文件。一直没有问题。突然有点报错了。。报错信息如下:
C:\Python\lib\site-packages\pydub\utils.py:165: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
C:\Python\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/sunlei/PycharmProjects/AutoSengItchat/demo.py", line 5, in <module>
song = AudioSegment.from_mp3("video\\190514-110500.mp3").set_frame_rate(8000).set_sample_width(2).set_channels(1)
File "C:\Python\lib\site-packages\pydub\audio_segment.py", line 716, in from_mp3
return cls.from_file(file, 'mp3', parameters=parameters)
File "C:\Python\lib\site-packages\pydub\audio_segment.py", line 665, in from_file
info = mediainfo_json(orig_file)
File "C:\Python\lib\site-packages\pydub\utils.py", line 263, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "C:\Python\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Python\lib\subprocess.py", line 990, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
网上解决方案有好多。但是一直没有找到合适的。。
后来通过测试。。发现 原来是配置好的 ffmpeg环境变量没有了。。。配置好的 环境变量为啥平白无故失踪了呢?估计可能是我手滑误删了?测试如下:
解决方法:找到 ffmpeg 位置重新配置环境变量就可以解决
ffmpeg的bin 目录添加到path变量里