def subTitle(text_file, video_file, output='out_sub.mp4'):
video1 = VideoFileClip(video_file)
sentences = [] # 台词列表
with open(text_file) as f:
text_tmp = f.readlines()
for i in text_tmp:
sentences.append(i.strip().split(':'))
print(sentences)
txts = [] # 所有字幕剪辑
with open('args.txt') as f:
color = f.readlines()[4].strip()
for sentence, span, start in sentences:
txt = (TextClip(sentence, fontsize=50, align='center', color=color, font='SimHei')
.set_position(("center","bottom")).set_duration(int(span)).set_start(int(start)))
txts.append(txt)