目录
vfx调用方法
变速moviepy.video.fx.accel_decel
黑白特效moviepy.video.fx.blackwhite
闪烁特效moviepy.video.fx.blink
色彩增幅moviepy.video.fx.colorx
裁剪moviepy.video.fx.crop
尺寸均匀moviepy.video.fx.even_size(剪裁视频像素为偶数)
淡入淡出moviepy.video.fx.fadein\fadeout
冷冻特效moviepy.video.fx.freeze_region\freeze
视频剪辑的伽玛校正moviepy.video.fx.gamma_corr
局部模糊特效moviepy.video.fx.headblur
色彩反转moviepy.video.fx.invert_colors
循环moviepy.video.fx.loop
亮度/对比度调整moviepy.video.fx.lum_contrast
结尾逐渐淡入使自己可循环moviepy.video.fx.make_loopable
页边距moviepy.video.fx.margin
遮罩moviepy.video.fx.mask_and\mask_or\mask_color
镜像moviepy.video.fx.mirror_x\mirror_y
油画特效moviepy.video.fx.painting
缩放moviepy.video.fx.resize
旋转moviepy.video.fx.rotate
滚动moviepy.video.fx.scroll
倍速moviepy.video.fx.speedx
倒放moviepy.video.fx.time_mirror
正播倒播自动合成moviepy.video.fx.time_symmetrize
moviepy.video.fx.supersample
vfx调用方法
方法一:
from moviepy.editor import VideoFileClip, vfx
video = VideoFileClip('video.mp4', audio=False)
factor = 2 # 倍速播放倍数
final_duration = 1 # 倍速播放持续时间
newclip = (video.fx(vfx.speedx, factor, final_duration))
newclip.write_videofile('1.mp4')
方法二:
newclip = vfx.speedx(video, factor, final_duration)
newclip.write_videofile('1.mp4')
变速moviepy.video.fx.accel_decel
# def accel_decel(clip, new_duration=None, abruptness=1.0, soonness=1.0):
# 參數:
# new_duration:最后视频时长,默认是clip原时长
# abruptness:加速时间
# soonness:加速持续时间
newclip = vfx.accel_decel(video, new_duration=None, abruptness=10, soonness=10)
黑白特效moviepy.video.fx.blackwhite
# def blackwhite(clip, RGB=None, preserve_luminosity=True):
# 參數:
# RGB:可选"CRT_phosphor",一组特殊值:[0.2125, 0.7154, 0.0721]
# preserve_luminosity:是否保持亮度,即preserve_luminosity是否与RGB的和保持为1
newclip = vfx.blackwhite(video)
闪烁特效moviepy.video.fx.blink
# def blink(clip, d_on, d_off):
# 參數:
# 仅在composite clips中生效
# d_on:每d_on秒显示
# d_off:每s_off秒消失
video = VideoFileClip('video.mp4').set_opacity(.5)
newclip = vfx.blink(video, d_on=2, d_off=3)
色彩增幅moviepy.video.fx.colorx
# def colorx(clip, factor):
# 參數:
# factor:增幅系数
video = VideoFileClip('demo_video.mp4').set_opacity(.5)
newclip = vfx.colorx(video, factor=.8)
裁剪moviepy.video.fx.crop
# def crop(clip, x1=None, y1=None, x2=None, y2=None, width=None, height=None, x_center=None, y_center=None,):
# 參數:
# 可以任意参数值组合完成裁剪...
# x1、y1表示裁剪区域的左上角坐标
# x2、y2表示裁剪区域的右下角坐标
# width、height表示裁剪区域宽度、高度
# x_center、y_center表示裁剪区域中心坐标
# (所有的坐标都以像素为单位,值为浮点数)
尺寸均匀moviepy.video.fx.even_size(剪裁视频像素为偶数)
def even_size(clip): # 裁剪剪辑,使尺寸均匀
淡入淡出moviepy.video.fx.fadein\fadeout
# def fadein(clip, duration, initial_color=None): # 淡入
# 參數:
# duration:变化时长
# initial_color:初始颜色(介于0和1之间的数字)
#
# def fadeout(clip, duration, final_color=None): # 淡出
# 參數:
# duration:变化时长
# final_color:终止颜色(介于0和1之间的数字)
newclip = vfx.fadein(video, duration=5, initial_color=.5)
newclip = vfx.fadeout(video, duration=3, final_color=.5)
冷冻特效moviepy.video.fx.freeze_region\freeze
# 局部冷冻特效
# def freeze_region(clip, t=0, region=None, outside_region=None, mask=None):
# 參數:
# t:冻结时刻
# region:冻结区域
# outside_region:非冻结区域
# mask:
# 冷冻特效
# def freeze(clip, t=0, freeze_duration=None, total_duration=None, padding_end=0):
# 參數:
# t:冻结时刻
# freeze_duration:冻结持续时间
# total_duration:总持续时间
# padding_end:
视频剪辑的伽玛校正moviepy.video.fx.gamma_corr
def gamma_corr(clip, gamma):
參數:
gamma:CRT的影像亮度呈现线性
局部模糊特效moviepy.video.fx.headblur
# def headblur(clip, fx, fy, r_zone, r_blur=None):
# 參數:
# fx、fy:模糊原点坐标
# r_zone:模糊半径
# r_blur:模糊强度
色彩反转moviepy.video.fx.invert_colors
# def invert_colors(clip):
循环moviepy.video.fx.loop
# def loop(clip, n=None, duration=None):
# 參數:
# n:循环次数
# duration:持续时间
亮度/对比度调整moviepy.video.fx.lum_contrast
# def lum_contrast(clip, lum=0, contrast=0, contrast_thr=127):
# 參數:
# lum:亮度
# contrast:对比度
# contrast_thr:
结尾逐渐淡入使自己可循环moviepy.video.fx.make_loopable
# def make_loopable(clip, cross):
# 參數:
# cross:淡入持续时间
页边距moviepy.video.fx.margin
# def margin(clip, mar=None, left=0, right=0, top=0, bottom=0, color=(0, 0, 0), opacity=1.0):
# 參數:
# mar:外边框的宽度像素,mar指定了有效值,left、right、top、bottom设定不起作用
# left,right,top,bottom:边框左、右、顶和底的宽度
# color:边框颜色
# opacity:边框透明度,0完全透明,1完全不透明
遮罩moviepy.video.fx.mask_and\mask_or\mask_color
# def mask_and(clip, other_clip):
# def mask_or(clip, other_clip):
# def mask_color(clip, color=None, thr=0, s=1):
镜像moviepy.video.fx.mirror_x\mirror_y
# def mirror_x(clip, apply_to="mask"):
# def mirror_y(clip, apply_to="mask"):
油画特效moviepy.video.fx.painting
# def painting(clip, saturation=1.4, black=0.006):
缩放moviepy.video.fx.resize
# def resize(clip, newsize=None, height=None, width=None, apply_to_mask=True):
旋转moviepy.video.fx.rotate
# def rotate(clip, angle, unit="deg", resample="bicubic", expand=True):
滚动moviepy.video.fx.scroll
# def scroll(clip, w=None, h=None, x_speed=0, y_speed=0, x_start=0, y_start=0, apply_to="mask"):
倍速moviepy.video.fx.speedx
# def speedx(clip, factor=None, final_duration=None):
倒放moviepy.video.fx.time_mirror
# def time_mirror(self):
正播倒播自动合成moviepy.video.fx.time_symmetrize
# def time_symmetrize(clip):
moviepy.video.fx.supersample
# def supersample(clip, d, nframes):