如图所示,我在运行脚本时收到此错误
测试.py
from pydub import AudioSegment
wav_audio = AudioSegment.from_file("Broken Summer.m4a", format="m4a")
wav_audio.export("audio1.mp3", format="mp3")
错误如下图C:\Python\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:\Python\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/karti/Documents/Python Programs/ChatApplication/deezer.py", line 13, in <module>
wav_audio = AudioSegment.from_file("Broken Summer.m4a", format="m4a")
File "C:\Python\lib\site-packages\pydub\audio_segment.py", line 685, in from_file
info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
File "C:\Python\lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "C:\Python\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Python\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
最佳答案
即使添加了 ffmpeg 的依赖项,很可能也不会读取该文件。由于 pydub 不读取 .m4a 文件这一事实。主要是因为 'ffmpeg' 通过 'libav' 库不支持这种类型的文件。
我也遇到了麻烦。
关于python - 将 .m4a 文件转换为 .mp3 时出现此错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63215295/