看了,还是自己弄这些方便。

#字幕

>>> from moviepy.video.tools.subtitles import SubtitlesClip
>>> from moviepy.video.io.VideoFileClip import VideoFileClip
>>> generator = lambda txt: TextClip(txt, font='Georgia-Regular',
fontsize=24, color='white')
>>> sub = SubtitlesClip("subtitles.srt", generator)
>>> myvideo = VideoFileClip("myvideo.avi")
>>> final = CompositeVideoClip([clip, subtitles])
>>> final.to_videofile("final.mp4", fps=myvideo.fps)
#前后播放
from moviepy.editor import VideoFileClip, concatenate_videoclips
clip1 = VideoFileClip("myvideo.mp4")
clip2 = VideoFileClip("myvideo2.mp4").subclip(50,60)
clip3 = VideoFileClip("myvideo3.mp4")
final_clip = concatenate_videoclips([clip1,clip2,clip3])
final_clip.write_videofile("my_concatenation.mp4")
#同屏播放
from moviepy.editor import VideoFileClip, clips_array, vfx
clip1 = VideoFileClip("myvideo.mp4").margin(10) # add 10px contour
clip2 = clip1.fx( vfx.mirror_x)
clip3 = clip1.fx( vfx.mirror_y)
clip4 = clip1.resize(0.60) # downsize 60%
final_clip = clips_array([[clip1, clip2],
[clip3, clip4]])
final_clip.resize(width=480).write_videofile("my_stack.mp4")
#淡入淡出
video = CompositeVideoClip([clip1, # starts at t=0
clip2.set_start(5).crossfadein(1),
clip3.set_start(9).crossfadein(1.5)])
# 水印位置,大小屏
video = CompositeVideoClip([clip1,
clip2.set_pos((45,150)),
clip3.set_pos((90,100))])
clip2.set_pos((45,150)) # x=45, y=150 , in pixels

clip2.set_pos("center") # automatically centered

# clip2 is horizontally centered, and at the top of the picture
clip2.set_pos(("center","top"))

# clip2 is vertically centered, at the left of the picture
clip2.set_pos(("left","center"))

# clip2 is at 40% of the width, 70% of the height of the screen:
clip2.set_pos((0.4,0.7), relative=True)

# clip2's position is horizontally centered, and moving down !
clip2.set_pos(lambda t: ('center', 50+t) )
# 视频导入处理
from moviepy.editor import *
clip = (VideoFileClip("myvideo.avi")
.fx( vfx.resize, width=460) # resize (keep aspect ratio)
.fx( vfx.speedx, 2) # double the speed
.fx( vfx.colorx, 0.5)) # darken the picture
#文字嵌入
# Generate a text clip. You can customize the font, color, etc.
txt_clip = TextClip("My Holidays 2013",fontsize=70,color='white')

# Say that you want it to appear 10s at the center of the screen
txt_clip = txt_clip.set_pos('center').set_duration(10)

# Overlay the text clip on the first video clip
video = CompositeVideoClip([clip, txt_clip])
#预览
my_clip.show() # shows the first frame of the clip
my_clip.show(10.5) # shows the frame of the clip at t=10.5s
my_clip.show(10.5, interactive = True)
my_clip.preview() # preview with default fps=15
my_clip.preview(fps=25)
my_clip.preview(fps=15, audio=False) # don't generate/play the audio.
my_audio_clip.preview(fps=22000)
ipython_display(my_video_clip) # embeds a video
ipython_display(my_imageclip) # embeds an image
ipython_display(my_audio_clip) # embeds a sound

ipython_display("my_picture.jpeg") # embeds an image
ipython_display("my_video.mp4") # embeds a video
ipython_display("my_sound.mp3") # embeds a sound
#多加音轨
videoclip2 = videoclip.set_audio(my_audioclip)
#登陆视频clip剪辑方法总结
# VIDEO CLIPS
clip = VideoClip(make_frame, duration=4) # for custom animations (see below)
clip = VideoFileClip("my_video_file.mp4") # or .avi, .webm, .gif ...
clip = ImageSequenceClip(['image_file1.jpeg', ...], fps=24)
clip = ImageClip("my_picture.png") # or .jpeg, .tiff, ...
clip = TextClip("Hello !", font="Amiri-Bold", fontsize=70, color="black")
clip = ColorClip(size=(460,380), color=[R,G,B])
#有用的url
https://zulko.github.io/moviepy/getting_started/videoclips.html

最新文章

  1. 12.super关键字
  2. java 特性
  3. java的各种类型转换汇总
  4. Delphi数组
  5. 使用Eclipse构建Maven项目 (转)
  6. jQuery validate基本原则
  7. oom日志查看
  8. Python 多线程学习(转)
  9. Domain Driven Design and Development In Practice--转载
  10. SQL Server数据库的操作流程和连接的简单介绍
  11. 基于mini2440的看门狗(裸机)
  12. bootstrap+jQuery.validate
  13. JavaScript 再认识(一):Function调用模式对this的影响
  14. 半个月学习的it内容
  15. 关于解决Tomcat服务器Connection reset by peer 导致的宕机
  16. MongoDB的搭建并配置主从以及读写分离
  17. FMT 与 子集(逆)卷积
  18. 从mysql主从复制到微信开源的phxsql
  19. CSS3背景相关新增属性
  20. phpstorm之ssh链接远程Linux服务器

热门文章

  1. node框架那些事儿
  2. spring boot的actuator
  3. Dede后台验证码不显示解决方法详解(dedecms 5.7 UTF-8版本)
  4. 记一次修复yum被破坏
  5. C语言的变参列表 va_list
  6. python笔记:删除列表元素和根据索引查找元素
  7. Django开发之module
  8. pytest_allure2 生成html报告
  9. JVM 参数调优配置
  10. [golang]使用gomail发邮件(在Go中发送电子邮件的最佳方式)