moviepy草碼

第一下。ide

# coding=utf-8

from moviepy.editor import *
from moviepy.video.tools.subtitles import SubtitlesClip


generator = lambda txt: TextClip(txt, font='SimHei', fontsize=24, color='black')

sub = SubtitlesClip("demo.srt", generator)
main_clip = VideoFileClip("main_clip.mp4").subclip(0, 9.0).resize((700, 500)).crossfadein(0.5).crossfadeout(0.5)
left_clip = VideoFileClip("left_clip.mp4").subclip(0, 9.0).resize((300, 500)).crossfadein(0.5).crossfadeout(0.5)
img_clip = ImageClip("wzj_cover.png", duration=3).fx(vfx.resize, width=300)

right_clip = CompositeVideoClip([main_clip, sub])

final_clip = clips_array([[left_clip, main_clip]])
final_clip.resize(width=1000, height=500).write_videofile("my_stack.mp4")

 srt文件的規則(最後不要有多的空行,序號,空行,時間軸,都是嚴謹的)spa

1
00:00:01,410 --> 00:00:04,740
這是隻小松鼠!

2
00:00:05,410 --> 00:00:07,740
這是隻小松鼠!
相關文章
相關標籤/搜索