标签:font tools tar cat mirror utf-8 ota segment djang
这个要比前一个厚实点。
更改视频亮度,增加字幕,去除音轨,淡入特效,转换,截取时间,控制位置,组合图框,合成多段,
嗯,很多都有了。
from django.test import TestCase # Create your tests here. # coding=utf-8 from moviepy.editor import * from moviepy.video.tools.subtitles import SubtitlesClip from moviepy.video.fx import volumex, resize, mirrorx, lum_contrast from moviepy.video.tools.segmenting import findObjects # 导入字幕 generator = lambda txt: TextClip(txt, font=‘SimHei‘, fontsize=24, color=‘black‘) sub = SubtitlesClip("welcome.srt", generator) # 片头 start_clip = VideoFileClip("start_clip.mp4").subclip(0, 9.0).resize((500, 1000)).fx(lum_contrast, (lum=0, contrast=0, contrast_thr=127)).crossfadein(0.5).crossfadeout(0.5) # 合成字幕 start_clip = CompositeVideoClip([start_clip, sub]) # 片尾 end_clip = ImageClip("wzj_cover.png").subclip(0, 9.0).resize((500, 1000)).fx(resize, (1000, 500)) # 内容 main_clip = VideoFileClip("main_clip.mp4", audio=False).without_audio().subclip(0, 9.0).on_color(color=(255, 255, 255)).resize((700, 500)).crossfadein(0.5).crossfadeout(0.5) left_clip1 = VideoFileClip("left_clip.mp4", audio=False).without_audio().subclip(0, 9.0).rotate(90).on_color(color=(255, 255, 255)) left_clip2 = VideoFileClip("left_clip.mp4", audio=False).without_audio().subclip(0, 9.0).rotate(90).on_color(color=(255, 255, 255)) left_clip3 = VideoFileClip("left_clip.mp4", audio=False).without_audio().subclip(0, 9.0).rotate(90).on_color(color=(255, 255, 255)) # 一种实现,通过巧妙堆叠 left_clip = clips_array([[left_clip, main_clip]]) mid_clip = clips_array([[left_clip, main_clip]]) """ # 另一种实现,通过画好的线框来安置视频 # Load the image specifying the regions. im = ImageClip("motif.png") # Loacate the regions, return a list of ImageClips regions = findObjects(im) clips = [left_clip1, left_clip2, left_clip3, main_clip] comp_clips = [c.resize(r.size) .set_mask(r.mask) .set_position(r.screenpos) for c,r in zip(clips,regions)] mid_clip = CompositeVideoClip(comp_clips, im.size) """ mid_clip = mid_clip.resize(width=1000, height=500).rotate(90) # 剪辑合成 final_clip = concatenate_videoclips([start_clip, mid_clip, end_clip]) # 输出视频 final_clip.write_videofile("my_stack.mp4")
标签:font tools tar cat mirror utf-8 ota segment djang
原文地址:https://www.cnblogs.com/aguncn/p/11022333.html