如何解决此错误:AttributeError:“非类型”对象没有属性“write\u audiofile”

2024-06-14 05:18:16 发布

您现在位置:Python中文网/ 问答频道 /正文

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'

Tags: oftheimporthomeparametervideowithlocation
1条回答
网友
1楼 · 发布于 2024-06-14 05:18:16

看起来video.audio的值是None,这是python的空值

空值没有任何属性,因此在尝试访问不存在的属性时,您将获得AttributeError

在这种情况下,这可能意味着moviepy无法在video2.mp4中找到音频

您可以通过拨打以下电话获得更多信息:

print(video.reader.infos)

相关问题 更多 >