moviepy图片和文字合成视频

from moviepy.editor import *

if __name__ == '__main__':
    # 读取视频
    clip = VideoFileClip("1.jpg").set_duration(10)
    # 文字视频
    text_clip: TextClip = TextClip("显示中文,不仅仅是English", font='STXINGKA.TTF', fontsize=70, color='black')

    # text_clip = text_clip.set_position("center").set_duration(10)
    text_clip = text_clip.set_position((10,20)).set_duration(10)

    # 合成视频
    composite_video_clip = CompositeVideoClip([clip, text_clip])

    # 导出视频
    composite_video_clip.write_videofile("2.mp4")

你可能感兴趣的:(python,moviepy)