目的:
错误:
A
脚本:
"concatenate.py", line 71, in concatenate_videoclips
tt = np.cumsum([0] + [c.duration for c in clips])
AttributeError: 'str' object has no attribute 'duration'"
问题:为什么" concatenate_videoclips()"接受硬编码列表但是当我将列表传递给它时失败。
答案 0 :(得分:0)
您创建VideoFileClip(clip)
但不添加到列表中,因此您将包含文件名的列表发送到concatenate_videoclips
中需要
new_list
def open_clips(clips):
new_list = []
for clip in clips:
new_list.append(VideoFileClip(clip))
combine_clips(new_list)
编辑:更短:
import os
from moviepy.editor import *
clips = []
for filename in os.listdir('.'):
if filename.endswith(".mov"):
clips.append(VideoFileClip(filename))
video = concatenate_videoclips(clips, method='compose')
video.write_videofile('ct_01.mp4')