【发布时间】:2021-09-15 20:46:15
【问题描述】:
我正在尝试制作 DAW,但每当我尝试运行代码时,都会遇到相同的错误。 即使我输入了正确的路径,也找不到我的文件。 代码:
import getpass
from pydub import AudioSegment
username=getpass.getuser()
song=AudioSegment.from_mp3('C:\\Users\\sanch\\Documents\\Cryo DAW\\bad_patty!.mp3')
错误:
Warning (from warnings module):
File "C:\Users\sanch\AppData\Local\Programs\Python\Python39\lib\site-packages\pydub\utils.py", line 170
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
Warning (from warnings module):
File "C:\Users\sanch\AppData\Local\Programs\Python\Python39\lib\site-packages\pydub\utils.py", line 198
warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
Traceback (most recent call last):
File "C:/Users/sanch/Documents/Python Projects/Cryo DAW.py", line 4, in <module>
song=AudioSegment.from_mp3('C:\\Users\\sanch\\Documents\\Cryo DAW\\bad_patty!.mp3')
File "C:\Users\sanch\AppData\Local\Programs\Python\Python39\lib\site-packages\pydub\audio_segment.py", line 796, in from_mp3
return cls.from_file(file, 'mp3', parameters=parameters)
File "C:\Users\sanch\AppData\Local\Programs\Python\Python39\lib\site-packages\pydub\audio_segment.py", line 728, in from_file
info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
File "C:\Users\sanch\AppData\Local\Programs\Python\Python39\lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "C:\Users\sanch\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\sanch\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
请帮忙!
【问题讨论】:
-
找不到的不是您的音频文件,而是
ffmpeg。该模块是ffmpeg工具的薄包装,您显然没有。您需要安装ffmpeg,并且可能需要告诉模块在哪里可以找到它。