【问题标题】:Errors while using PyDub. How do I fix?使用 PyDub 时出错。我该如何解决?
【发布时间】: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,并且可能需要告诉模块在哪里可以找到它。

标签: python ffprobe pydub


【解决方案1】:
  • 如果您在 Linux 上,只需安装 ffmpeg 和 libavcodec-extra:
    • $ sudo apt-get install ffmpeg libavcodec-extra
      
  • 然后安装 pydub 库,您的错误将得到修复:
    • $ pip3 install pydub
      

【讨论】:

    猜你喜欢
    • 2013-12-24
    • 2016-06-19
    • 1970-01-01
    • 2021-12-13
    • 2019-06-24
    • 2019-06-28
    • 2023-02-22
    • 1970-01-01
    • 2022-07-12
    相关资源
    最近更新 更多