You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已安装FFmpeg但PyDub无法定位问题求助(Windows11环境)

问题:PyDub无法找到FFmpeg(已配置环境变量且其他模块可用)

环境配置

  • Windows 11系统
  • Python 3.10.6
  • PyDub 0.25.1
  • FFmpeg版本:2023-04-12-git-1179bb703e-full_build

问题详情

已通过命令行确认FFmpeg安装配置正确并加入系统环境变量,其他依赖FFmpeg的模块(如moviepy)可正常运行,但使用PyDub加速MP3时,始终出现找不到FFmpeg的错误。即使在代码中手动指定FFmpeg绝对路径AudioSegment.ffmpeg_path = r"C:\ffmpeg\bin\ffmpeg.exe",问题仍未解决。

尝试的代码

import os
from pydub import AudioSegment

file = r'test.mp3'

# 加载MP3文件
audio = AudioSegment.from_file(file, format="mp3")

# 加速音频
audio = audio.speedup(playback_speed=2, chunk_size=150)

# 导出修改后的文件覆盖原文件
audio.export(file, format="mp3")

# 删除原文件
os.remove(file)

报错信息

C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\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)
C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\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 "c:\Users\xxx\xxx\xxx\xxx\xxx\speed_up.py", line 7, in <module>
    audio = AudioSegment.from_file(file, format="mp3")
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\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\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1438, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

其他模块验证(moviepy正常运行)

from moviepy.editor import ColorClip

# 创建一个5秒的黑色视频片段
empty_clip = ColorClip(size=(640, 480), color=(0, 0, 0), duration=5)

# 将片段导出为视频文件
empty_clip.write_videofile("empty.mp4", codec="libx264", fps=25)

内容的提问来源于stack exchange,提问作者TordG

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 17:53:24