我正在做一个验证码解译器,我需要使用ffmpeg,虽然没什么用。Windows 10用户。
第一次运行代码时警告:
C:\Users\user\AppData\Roaming\Python\Python310\site-packages\pydub\utils.py:170: 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)
然后,当我尝试运行脚本时,它需要ff探头,我得到了以下错误:
C:\Users\user\AppData\Roaming\Python\Python310\site-packages\pydub\utils.py:198: 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 "D:\Scripts\captcha\main.py", line 164, in <module>
main()
File "D:\Scripts\captcha\main.py", line 155, in main
captchaSolver()
File "D:\Scripts\captcha\main.py", line 106, in captchaSolver
sound = pydub.AudioSegment.from_mp3(
File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\pydub\audio_segment.py", line 796, in from_mp3
return cls.from_file(file, 'mp3', parameters=parameters)
File "C:\Users\user\AppData\Roaming\Python\Python310\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\user\AppData\Roaming\Python\Python310\site-packages\pydub\utils.py", line 274, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "C:\Program Files\Python310\lib\subprocess.py", line 966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files\Python310\lib\subprocess.py", line 1435, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
我试着正常下载它,编辑环境变量,将它们粘贴在与脚本相同的文件夹中,用pip安装,手动测试ffmpeg以查看它是否有效,实际上它将mkv转换为mp4,但是我的脚本无意运行。
发布于 2022-12-02 11:27:47
正如您从错误消息中看到的那样,问题在于ffprobe
而不是ffmpeg
。
确保ffprobe.exe
和ffmpeg.exe
都在可执行路径中。
ffprobe.exe
和ffmpeg.exe
放在与D:\Scripts\captcha\
脚本相同的文件夹中(在您的例子中是D:\Scripts\captcha\
),ffprobe.exe
和ffmpeg.exe
文件夹添加到Windows路径中。(将EXE文件放置在系统路径中的文件夹中也可能有效)。
调试Pydub源代码(pydub-0.25.1):
代码在以下代码中失败:
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
# no special security
None, None,
int(not close_fds),
creationflags,
env,
os.fspath(cwd) if cwd is not None else None,
startupinfo)
其中args = 'ffprobe -of json -v info -show_format -show_streams test.mp3'
我们从以下地点到达:
info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
发自:
prober = get_prober_name()
以下是get_prober_name
方法的源代码:
def get_prober_name():
"""
Return probe application, either avconv or ffmpeg
"""
if which("avprobe"):
return "avprobe"
elif which("ffprobe"):
return "ffprobe"
else:
# should raise exception
warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
return "ffprobe"
which
方法在执行路径中查找命令(如果没有找到,则返回None
)。
从Pydub源代码中可以看到,ffprobe.exe
应该在执行路径中。
对于设置FFmpeg路径,我们还可以应用如下内容:
进口pydub pydub.AudioSegment.converter = 'c:\FFmpeg\bin\ffmpeg.exe‘声音=c:\FFmpeg\bin\ffmpeg.exe
但FFprobe没有这样的选择。
https://stackoverflow.com/questions/74651215
复制相似问题