当前位置: 首页 > 工具软件 > MoviePy > 使用案例 >

Moviepy超实用手册

宗政权
2023-12-01

moviepy vfx,当前版本:2.0.0.dev2,非特殊说明即在原视频上进行变化

目录

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.supersample

moviepy.video.fx.time_mirror(倒放)time_symmetrize(正播倒播自动合成)


 

vfx调用方法

from moviepy.editor import VideoFileClip, vfx


video = VideoFileClip('demo.mp4', audio=False).subclip(0, 3)
factor = 2 # 倍速播放倍数
final_duration = 1 # 倍速播放持续时间 ,可以为空表使全部

# 方式一
newclip = (video
           .fx(vfx.speedx, factor , final_duration)
          )
# 方式二
newclip = vfx.speedx(video, factor, final_duration)

newclip.preview()

moviepy.video.fx.accel_decel  变速

def accel_decel(clip, new_duration=None, abruptness=1.0, soonness=1.0):
    """
    new_duration:最后视频时长,默认是clip原时长
    abruptness:加速时间,(>-1 and <0)加速降速(0)无影响(>0)降速加速
    soonness:加速持续时间,(0<soonness < inf)
    """
    pass

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
    """
    pass

moviepy.video.fx.blink  闪烁特效

def blink(clip, d_on, d_off):
    """
    仅在composite clips中生效
    d_on:每d_on秒显示
    d_off:没s_off秒消失
    (返回一个新剪辑(clip),不在原剪辑上操作)
    """
    pass

moviepy.video.fx.colorx  色彩增幅

def colorx(clip, factor):
    """
    factor:增幅系数
    """
    pass

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表示裁剪区域中心坐标
    (所有的坐标都以像素为单位,值为浮点数)
    """
    pass

moviepy.video.fx.even_size  尺寸均匀(剪裁视频像素为偶数)

def even_size(clip):
    """
    Crops the clip to make dimensions even.
    """
    pass

moviepy.video.fx.fadein\fadeout  淡入淡出

def fadein(clip, duration, initial_color=None):
    """
    duration:变化时长
    initial_color:初始颜色(介于0和1之间的数字)
    """
    pass

def fadeout(clip, duration, final_color=None):
    """
    duration:变化时长
    final_color:终止颜色(介于0和1之间的数字)
    """
    pass

moviepy.video.fx.freeze_region\freeze  冷冻特效

# 局部冷冻特效
def freeze_region(clip, t=0, region=None, outside_region=None, mask=None):
    """
    t:冻结时刻
    region:冻结区域
    outside_region:非冻结区域
    mask:
    """
    pass

# 冷冻特效
def freeze(clip, t=0, freeze_duration=None, total_duration=None, padding_end=0):
    """
    t:
    freeze_duration:冻结持续时间
    total_duration:总持续时间
    padding_end:
    """
    pass

moviepy.video.fx.gamma_corr  视频剪辑的伽玛校正

def gamma_corr(clip, gamma):
    """
    gamma:CRT的影像亮度呈现线性
    """
    pass

moviepy.video.fx.headblur  局部模糊特效

def headblur(clip, fx, fy, r_zone, r_blur=None):
    """
    fx、fy:模糊原点坐标
    r_zone:模糊半径
    r_blur:模糊强度
    """
    pass

moviepy.video.fx.invert_colors  色彩反转

def invert_colors(clip):
    pass

moviepy.video.fx.loop  循环

def loop(clip, n=None, duration=None):
    """
    n:循环次数
    duration:持续时间
    """
    pass

moviepy.video.fx.lum_contrast  亮度、对比度调整

def lum_contrast(clip, lum=0, contrast=0, contrast_thr=127):
    """
    lum:亮度
    contrast:对比度
    contrast_thr:
    """
    pass

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完全不透明
    """
    pass

moviepy.video.fx.mask_and\mask_or\mask_color遮罩

def mask_and(clip, other_clip):
    """
    other_clip:
    """
    pass

def mask_or(clip, other_clip):
    """
    other_clip:
    """
    pass

def mask_color(clip, color=None, thr=0, s=1):
    """
    color:
    thr:
    s:
    """
    pass

moviepy.video.fx.mirror_x\mirror_y镜像

def mirror_x(clip, apply_to="mask"):
    pass

def mirror_y(clip, apply_to="mask"):
    pass

moviepy.video.fx.painting  油画特效

def painting(clip, saturation=1.4, black=0.006):
    """
    saturation:
    black:
    """
    pass

moviepy.video.fx.resize  缩放

def resize(clip, newsize=None, height=None, width=None, apply_to_mask=True):
    pass

moviepy.video.fx.rotate  旋转

def rotate(clip, angle, unit="deg", resample="bicubic", expand=True):
    pass

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"
):
    pass

moviepy.video.fx.speedx  倍速

def speedx(clip, factor=None, final_duration=None):
    pass

moviepy.video.fx.supersample

def supersample(clip, d, nframes):
    """
    d:
    nframes:
    """
    pass

moviepy.video.fx.time_mirror(倒放)time_symmetrize(正播倒播自动合成)

def time_mirror(self):
    pass

def time_symmetrize(clip):
    pass

 

 类似资料: