python+moviepy audio and video processing (3): video special effects method-vfx module

Table of contents

vfx calling method

variable speed moviepy.video.fx.accel_decel

black and white special effects moviepy.video.fx.blackwhite

color augmentation moviepy.video.fx.colorx

crop moviepy.video.fx.crop

Uniform size moviepy.video.fx.even_size (cropping video pixels to even numbers)

fade in and fade out moviepy.video.fx.fadein\fadeout

Freeze special effects moviepy.video.fx.freeze_region\freeze

Gamma correction for video clips moviepy.video.fx.gamma_corr

Partial blur effect moviepy.video.fx.headblur

Color inversion moviepy.video.fx.invert_colors

loop moviepy.video.fx.loop

Brightness/contrast adjustment moviepy.video.fx.lum_contrast

End fades in make itself loopable moviepy.video.fx.make_loopable

Margin moviepy.video.fx.margin

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

mirror moviepy.video.fx.mirror_x\mirror_y

Oil painting special effects moviepy.video.fx.painting

resize moviepy.video.fx.resize

rotate moviepy.video.fx.rotate

scroll moviepy.video.fx.scroll

Double speedmoviepy.video.fx.speedx

倒放moviepy.video.fx.time_mirror

Automatically synthesize moviepy.video.fx.time_symmetrize for forward broadcast and reverse broadcast

moviepy.video.fx.supersample


vfx calling method

method one:

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')

Method Two:

newclip = vfx.speedx(video, factor, final_duration)
newclip.write_videofile('1.mp4')

variable speed 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)

black and white special effects 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)
# 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)

color augmentation moviepy.video.fx.colorx

# def colorx(clip, factor):
# 參數:
#     factor:增幅系数

video = VideoFileClip('demo_video.mp4').set_opacity(.5)
newclip = vfx.colorx(video, factor=.8)

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

Uniform size moviepy.video.fx.even_size (cropping video pixels to even numbers)

def even_size(clip):  # 裁剪剪辑,使尺寸均匀

fade in and fade out 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)

Freeze special effects 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:

Gamma correction for video clips moviepy.video.fx.gamma_corr

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

Partial blur effect moviepy.video.fx.headblur

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

Color inversion moviepy.video.fx.invert_colors

# def invert_colors(clip):

loop moviepy.video.fx.loop

# def loop(clip, n=None, duration=None):
# 參數:
#     n:循环次数
#     duration:持续时间

Brightness/contrast adjustment moviepy.video.fx.lum_contrast

# def lum_contrast(clip, lum=0, contrast=0, contrast_thr=127):
# 參數:
#     lum:亮度
#     contrast:对比度
#     contrast_thr:

End fades in make itself loopable moviepy.video.fx.make_loopable

# def make_loopable(clip, cross):
# 參數:
#     cross:淡入持续时间

Margin 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):

mirror moviepy.video.fx.mirror_x\mirror_y

#  def mirror_x(clip, apply_to="mask"):
 
#  def mirror_y(clip, apply_to="mask"):

Oil painting special effects moviepy.video.fx.painting

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

resize moviepy.video.fx.resize

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

rotate moviepy.video.fx.rotate

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

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

Double speedmoviepy.video.fx.speedx

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

倒放moviepy.video.fx.time_mirror

# def time_mirror(self):

Automatically synthesize moviepy.video.fx.time_symmetrize for forward broadcast and reverse broadcast

#  def time_symmetrize(clip):

moviepy.video.fx.supersample

#  def supersample(clip, d, nframes):

Guess you like

Origin blog.csdn.net/JBY2020/article/details/128897799