我正在尝试运行以下代码:
from moviepy.editor import *
videoclip = VideoFileClip("filename.mp4")
audioclip = AudioFileClip("audioname.mp3")
new_audioclip = CompositeAudioClip([videoclip.audio, audioclip])
videoclip.audio = new_audioclip
videoclip.write_videofile("new_filename.mp4")
但是当我运行它时,出现以下错误:
* 追溯(最近一次通话):文件“ C:/ Users / arthu / PycharmProjects / Comprei da China / video.py”,第5行,在 new_audioclip = CompositeAudioClip([videoclip.audio,audioclip])文件“ C:\ Users \ arthu \ PycharmProjects \ Comprei da China \ venv \ lib \ site-packages \ moviepy \ audio \ AudioClip.py”,第285行,在 初始化 结尾= [c.end为self.clips中的c]文件“ C:\ Users \ arthu \ PycharmProjects \ Comprei da China \ venv \ lib \ site-packages \ moviepy \ audio \ AudioClip.py”,行285,在 ends = [c.end for self.clips中的c] AttributeError:'NoneType'对象没有属性'end' *
有人知道我该怎么解决吗?
答案 0 :(得分:0)
在CompositeAudioClip中仅传递一个参数,内置类AudioClip.py具有一个参数
from moviepy.editor import *
videoclip = VideoFileClip("filename.mp4")
audioclip = AudioFileClip("audioname.mp3")
new_audioclip = CompositeAudioClip([audioclip])
videoclip.audio = new_audioclip
videoclip.write_videofile("new_filename.mp4")