当前位置:优学网  >  在线题库

使用pydub库时FileNotFoundError

发表时间:2022-07-12 00:15:58 阅读:84

这就是我得到的:

from pydub import AudioSegment

AudioSegment.from_file("Somesong.webm").export("Samesong.mp3", format="mp3")

"Somesong.webm"与脚本位于同一目录中,但是,我收到了以下错误:

C:\Users\User\AppData\Roaming\Python\Python39\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\User\AppData\Roaming\Python\Python39\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\User\Documents\Projects\.vscode\Python\GD SONG REPLACE\main.py", line 24, in <module>
    AudioSegment.from_file("Creo - Sphere.webm").export("Creo - Sphere.mp3", format="mp3")
  File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\pydub\audio_segment.py", line 728, in from_file
  File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\pydub\utils.py", line 274, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
  File "C:\Program Files\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Program Files\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

我也试着输入文件的绝对路径,但错误不会消失.

🎖️ 优质答案
  • 如果它们在同一目录中,请尝试将"Somesong.webm"更改为"Somesong.webm",将"Samesong.mp3"更改为"Samesong.mp3"."."指示文件应与代码位于同一目录中.

    编辑:请注意,这是假设这是一个与文件相关的问题.可能是别的什么.我本想发表评论,但我没有足够的声誉这么做.

  • 相关问题