加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
moviePy_demo2.py 984 Bytes
一键复制 编辑 原始数据 按行查看 历史
龙猫69 提交于 2018-06-01 16:58 . up
import moviepy.editor as mpy
import skimage.exposure as ske
import skimage.filters as skf
clip = mpy.VideoFileClip("sinc.gif")
gray = clip.fx(mpy.vfx.blackwhite).to_mask()
def apply_effect(effect, label, **kw):
""" Returns a clip with the effect applied and a top label"""
filtr = lambda im: effect(im, **kw)
new_clip = gray.fl_image(filtr).to_RGB()
txt = (mpy.TextClip(label, font="Amiri-Bold", fontsize=25,
bg_color='white', size=new_clip.size)
.set_position(("center"))
.set_duration(1))
return mpy.concatenate_videoclips([txt, new_clip])
equalized = apply_effect(ske.equalize_hist, "Equalized")
rescaled = apply_effect(ske.rescale_intensity, "Rescaled")
adjusted = apply_effect(ske.adjust_log, "Adjusted")
blurred = apply_effect(skf.gaussian_filter, "Blurred", sigma=4)
clips = [equalized, adjusted, blurred, rescaled]
animation = mpy.concatenate_videoclips(clips)
animation.write_gif("sinc_cat.gif", fps=15)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化