moviepy vfx,当前版本:2.0.0.dev2,非特殊说明即在原视频上进行变化
目录
moviepy.video.fx.accel_decel 变速
moviepy.video.fx.blackwhite 黑白特效
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.lum_contrast 亮度、对比度调整
moviepy.video.fx.make_loopable 结尾逐渐淡入使自己可循环
moviepy.video.fx.mask_and\mask_or\mask_color遮罩
moviepy.video.fx.mirror_x\mirror_y镜像
moviepy.video.fx.painting 油画特效
moviepy.video.fx.time_mirror(倒放)time_symmetrize(正播倒播自动合成)
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()
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
def blackwhite(clip, RGB=None, preserve_luminosity=True):
"""
RGB:可选"CRT_phosphor",一组特殊值:[0.2125, 0.7154, 0.0721]
preserve_luminosity:是否保持亮度,即preserve_luminosity是否与RGB的和保持为1
"""
pass
def blink(clip, d_on, d_off):
"""
仅在composite clips中生效
d_on:每d_on秒显示
d_off:没s_off秒消失
(返回一个新剪辑(clip),不在原剪辑上操作)
"""
pass
def colorx(clip, factor):
"""
factor:增幅系数
"""
pass
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
def even_size(clip):
"""
Crops the clip to make dimensions even.
"""
pass
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
# 局部冷冻特效
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
def gamma_corr(clip, gamma):
"""
gamma:CRT的影像亮度呈现线性
"""
pass
def headblur(clip, fx, fy, r_zone, r_blur=None):
"""
fx、fy:模糊原点坐标
r_zone:模糊半径
r_blur:模糊强度
"""
pass
def invert_colors(clip):
pass
def loop(clip, n=None, duration=None):
"""
n:循环次数
duration:持续时间
"""
pass
def lum_contrast(clip, lum=0, contrast=0, contrast_thr=127):
"""
lum:亮度
contrast:对比度
contrast_thr:
"""
pass
def make_loopable(clip, cross):
"""
cross:淡入持续时间
"""
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
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
def mirror_x(clip, apply_to="mask"):
pass
def mirror_y(clip, apply_to="mask"):
pass
def painting(clip, saturation=1.4, black=0.006):
"""
saturation:
black:
"""
pass
def resize(clip, newsize=None, height=None, width=None, apply_to_mask=True):
pass
def rotate(clip, angle, unit="deg", resample="bicubic", expand=True):
pass
def scroll(
clip, w=None, h=None, x_speed=0, y_speed=0, x_start=0, y_start=0, apply_to="mask"
):
pass
def speedx(clip, factor=None, final_duration=None):
pass
def supersample(clip, d, nframes):
"""
d:
nframes:
"""
pass
def time_mirror(self):
pass
def time_symmetrize(clip):
pass