gpt4 book ai didi

python - 如何解决此错误 : AttributeError: 'NoneType' object has no attribute 'write_audiofile'

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

import moviepy.editor
# Replace the parameter with the location of the video


video = moviepy.editor.VideoFileClip("/home/amit/video2.mp4")
audio = video.audio


# Replace the parameter with the location along with filename
audio.write_audiofile("/home/amit/output.mp3")
这是代码并收到此错误:
AttributeError: 'NoneType' object has no attribute 'write_audiofile'

最佳答案

看来video.audio的值为None,也就是python的null值。
Null 值没有任何属性,因此在尝试访问不存在的属性时会收到 AttributeError。
在这种特定情况下,这可能意味着 moviepy 无法在 video2.mp4 中找到音频。
您可以通过以下方式获取更多信息:

print(video.reader.infos)

关于python - 如何解决此错误 : AttributeError: 'NoneType' object has no attribute 'write_audiofile' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67841071/

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