如何解决如何解决此错误:AttributeError: 'NoneType' object has no attribute 'write_audiofile'
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的空值。
空值没有任何属性,因此在尝试访问不存在的属性时会收到 AttributeError。
在这种特定情况下,这可能意味着 moviepy 无法在 video2.mp4 中找到音频。
您可以通过拨打以下电话获得更多信息:
print(video.reader.infos)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。