rogerxavier
commited on
Commit
•
a046690
1
Parent(s):
0cf9049
Update 3mergeDialogToVideo.py
Browse files- 3mergeDialogToVideo.py +6 -1
3mergeDialogToVideo.py
CHANGED
@@ -263,6 +263,9 @@ if __name__ == '__main__':
|
|
263 |
|
264 |
image_files = filtered_image_files
|
265 |
|
|
|
|
|
|
|
266 |
for idx, image_file in enumerate(image_files):
|
267 |
print("现在处理的图片是"+image_file)
|
268 |
#后面是视音频生成部分-这里图片需要用到完整的去水印的而不是对话框用于识别的
|
@@ -286,7 +289,9 @@ if __name__ == '__main__':
|
|
286 |
txt_clip = TextClip(cur_copywrite, fontsize=40, color='white', bg_color='black',
|
287 |
font=font_path) ##文本clip后加入视频
|
288 |
|
289 |
-
txt_clip = txt_clip.set_pos(('center', 'bottom')).set_duration(duration)
|
|
|
|
|
290 |
# 创建音频剪辑
|
291 |
audio_clip = AudioFileClip(filename)
|
292 |
clip = clip.set_audio(audio_clip) # 将音频与视频片段关联
|
|
|
263 |
|
264 |
image_files = filtered_image_files
|
265 |
|
266 |
+
#为了保证读完一句话显示下一句字幕,当前字幕消失,需要设置一个start time
|
267 |
+
start_time = 0 # 初始化字幕起始时间
|
268 |
+
|
269 |
for idx, image_file in enumerate(image_files):
|
270 |
print("现在处理的图片是"+image_file)
|
271 |
#后面是视音频生成部分-这里图片需要用到完整的去水印的而不是对话框用于识别的
|
|
|
289 |
txt_clip = TextClip(cur_copywrite, fontsize=40, color='white', bg_color='black',
|
290 |
font=font_path) ##文本clip后加入视频
|
291 |
|
292 |
+
txt_clip = txt_clip.set_pos(('center', 'bottom')).set_duration(duration).set_start(start_time)#这里除了设置字幕起始时间外再设置开始时间,保证字幕读完消失
|
293 |
+
start_time += duration # 更新字幕起始时间为当前文本片段的结束时间
|
294 |
+
|
295 |
# 创建音频剪辑
|
296 |
audio_clip = AudioFileClip(filename)
|
297 |
clip = clip.set_audio(audio_clip) # 将音频与视频片段关联
|