gpt4 book ai didi

python - CouldntDecodeError : Decoding failed. ffmpeg 返回错误代码:69

转载 作者:行者123 更新时间:2023-12-04 22:45:19 26 4
gpt4 key购买 nike

尝试使用 audiosegment.from_file(x.mp3) 打开一个 mp3 文件,然后通过 audio.export(x.mp3, format='wav '),我遇到以下 Couldnt DecodeError

这可能是什么原因造成的?我正在使用 python= 3.9pydub=0.25.1audiosegment=0.23.0

在此先感谢您的帮助。以下是控制台上显示的错误。

CouldntDecodeError                        Traceback (most recent call last)
/var/folders/vh/nmgr0zd56yd_vs_56q_jy89c0000gn/T/ipykernel_21698/1373432166.py in <module>
1 vad=wb.Vad()
2 filename= '/Users/gulag_dweller/Desktop/Lab_stuff/python_script/Isi_B1.mp3'
----> 3 audio= audiosegment.from_file(filename)
4 audio_wav= audio.export(filename, format ='wav')
5

~/mambaforge/lib/python3.9/site-packages/audiosegment.py in from_file(path)
1131 _name, ext = os.path.splitext(path)
1132 ext = ext.lower()[1:]
-> 1133 seg = pydub.AudioSegment.from_file(path, ext)
1134 return AudioSegment(seg, path)
1135

~/mambaforge/lib/python3.9/site-packages/pydub/audio_segment.py in from_file(cls, file, format, codec, parameters, start_second, duration, **kwargs)
771 if close_file:
772 file.close()
--> 773 raise CouldntDecodeError(
774 "Decoding failed. ffmpeg returned error code: {0}\n\nOutput from ffmpeg/avlib:\n\n{1}".format(
775 p.returncode, p_err.decode(errors='ignore') ))

CouldntDecodeError: Decoding failed. ffmpeg returned error code: 69

Output from ffmpeg/avlib:

ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
built with clang version 11.1.0

最佳答案

我遇到了同样的问题。我读到有些情况下 mp3 文件包含 AAC 音频,但容器格式是 mpeg4。

所以,对我有用的解决方案是:

try:
audio = audiosegment.from_file(filename, "mp3")
except:
audio = audiosegment.from_file(filename, format="mp4")

关于python - CouldntDecodeError : Decoding failed. ffmpeg 返回错误代码:69,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70660431/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com