1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from moviepy.editor import *

# 打开视频文件
video = VideoFileClip('dark.mp4')

# 剪辑视频
video2 = video.subclip(0,1)

# 添加文字、位置、显示时间
text = (TextClip("WPS",fontsize =20,color ="white",font ="黑体")
.set_position('center')
.set_duration(0.5))

# 在视频上加载文本
video_with_text = CompositeVideoClip([video2,text])

# 保存为新文件
video_with_text.write_videofile('new_1.mp4')