MoviePy - 中文文档4-MoviePy实战案例-重新构建15世纪舞蹈视频
回到目录
重新构建15世纪舞蹈视频
# -*- coding: utf-8 -*-"""
Result: https://www.youtube.com/watch?v=Qu7HJrsEYFgThis is how we can imagine knights dancing at the 15th century, based on a very
serious historical study here: https://www.youtube.com/watch?v=zvCvOC2VwDcHere is what we do:0- Get the video of a dancing knight, and a (Creative Commons) audio music file.
1- load the audio file and automatically find the tempo
2- load the video and automatically find a segment that loops well
3- extract this segment, slow it down so that it matches the audio tempo,and make it loop forever.
4- Symmetrize this segment so that we will get two knights instead of one
5- Add a title screen and some credits, write to a file.This example has been originally edited in an IPython Notebook, which makes it
easy to preview and fine-tune each part of the editing.
"""from moviepy.editor import *
from moviepy.video.tools.cuts import find_video_period
from moviepy.audio.tools.cuts import find_audio_period# Next lines are for downloading the required videos from Youtube.
# To do this you must have youtube-dl installed, otherwise you will need to
# download the videos by hand and rename them, as follows:
# https://www.youtube.com/watch?v=zvCvOC2VwDc => knights.mp4
# https://www.youtube.com/watch?v=lkY3Ek9VPtg => frontier.mp4import os
if not os.path.exists("knights.mp4"):os.system("youtube-dl zvCvOC2VwDc -o knights.mp4")os.system("youtube-dl lkY3Ek9VPtg -o frontier.mp4")
#==========# LOAD, EDIT, ANALYZE THE AUDIOaudio = (AudioFileClip("frontier.mp4").subclip((4,7), (4,18)).audio_fadein(1).audio_fadeout(1))audio_period = find_audio_period(audio)
print ('Analyzed the audio, found a period of %.02f seconds'%audio_period)# LOAD, EDIT, ANALYZE THE VIDEOclip = (VideoFileClip("./knights.mp4", audio=False).subclip((1,24.15),(1,26)).crop(x1=332, x2=910, y2=686))video_period = find_video_period(clip, tmin=.3)
print ('Analyzed the video, found a period of %.02f seconds'%video_period)edited_right = (clip.subclip(0,video_period).speedx(final_duration=2*audio_period).fx(vfx.loop, duration=audio.duration).subclip(.25))edited_left = edited_right.fx(vfx.mirror_x)dancing_knights = (clips_array([[edited_left, edited_right]]).fadein(1).fadeout(1).set_audio(audio).subclip(.3))# MAKE THE TITLE SCREENtxt_title = (TextClip("15th century dancing\n(hypothetical)", fontsize=70,font="Century-Schoolbook-Roman", color="white").margin(top=15, opacity=0).set_position(("center","top")))title = (CompositeVideoClip([dancing_knights.to_ImageClip(), txt_title]).fadein(.5).set_duration(3.5))# MAKE THE CREDITS SCREENtxt_credits = """
CREDITSVideo excerpt: Le combat en armure au XVe siècle
By J. Donzé, D. Jaquet, T. Schmuziger,
Université de Genève, Musée National de Moyen AgeMusic: "Frontier", by DOCTOR VOX
Under licence Creative Commons
https://www.youtube.com/user/DOCTORVOXofficialVideo editing © Zulko 2014Licence Creative Commons (CC BY 4.0)
Edited with MoviePy: http://zulko.github.io/moviepy/
"""credits = (TextClip(txt_credits, color='white',font="Century-Schoolbook-Roman", fontsize=35, kerning=-2,interline=-1, bg_color='black', size=title.size).set_duration(2.5).fadein(.5).fadeout(.5))# ASSEMBLE EVERYTHING, WRITE TO FILEfinal = concatenate_videoclips([title, dancing_knights, credits])final.write_videofile("dancing_knights.mp4", fps=clip.fps,audio_bitrate="1000k", bitrate="4000k")
一起交流,一起进步,群内提问答疑
QQ群:MoviePy中文 :819718037
回到目录
MoviePy - 中文文档4-MoviePy实战案例-重新构建15世纪舞蹈视频相关推荐
- MoviePy - 中文文档(一个专业的python视频编辑库)教程
MoviePy是一个用于视频编辑的python模块,你可以用它实现一些基本的操作(比如视频剪辑,视频拼接,插入标题),还可以实现视频合成,还有视频处理,抑或用它加入一些自定义的高级的特效.总之,它的功 ...
- MoviePy - 中文文档2-快速上手-创建和导出video clips
回到目录 创建和导出video clips video 和 audio clips是moviepy中的核心的对象.这篇博文,我们会介绍不同的短clip,展示如何创建他们,以及如何将它们导出到文件中.关 ...
- MoviePy - 中文文档2-快速上手-MoviePy-预览
下面的内容介绍以下MoviePy适用于何种场景以及MoviePy如何工作. 我需要使用MoviePy吗? 出于以下的情景或原因,我们可能会有使用Python做视频编辑的需求. *我们有大量的视频需要处 ...
- MoviePy - 中文文档4-MoviePy实战案例-把多个clip放置在一个画面中(超美)
把多个clip放置在一个画面中 这么复杂的合成,是怎么做出来的啊?! 在这个脚本中,我们会使用下面这个图: 我们将找到这些区域,然后把不同的clip填充到这些区域 from moviepy.edito ...
- MoviePy - 中文文档4-MoviePy实战案例-追踪人脸,打马赛克
回到目录 追踪人脸,打马赛克 首先,我们需要先追踪到人脸,即,获得两个函数fx和fy就像(fx(t), fy(t))获得某时刻t脸的中心的坐标,通过manual_tracking,这个功能很快就实现了 ...
- MoviePy - 中文文档4-MoviePy实战案例-炫动的字母特效
回到目录 炫动的字母特效 这个例子,一定能很好的地说明为什么大家有兴趣基于MoviePy脚本来实现一些特效,我们也可以想像一下如果是手工做的话,绝壁手抽筋了. 下面就是代码实现 import nump ...
- MoviePy - 中文文档4-MoviePy实战案例-给MoviePy Logo做一个闪动的阴影效果
回到目录 给MoviePy Logo做一个闪动的阴影效果 一起交流,一起进步,群内提问答疑 QQ群:MoviePy中文 :819718037 回到目录
- keras中文文档_【DL项目实战02】图像识别分类——Keras框架+卷积神经网络CNN(使用VGGNet)
版权声明:小博主水平有限,希望大家多多指导. 目录: [使用传统DNN] BG大龍:[DL项目实战02]图像分类--Keras框架+使用传统神经网络DNNzhuanlan.zhihu.com [使用 ...
- Python官方中文文档来了
你不一定要点蓝字关注我的 机器之心报道 参与:思源 Python 作为世界上最好用的语言,官方支持的文档一直没有中文.小伙伴们已经习惯了原汁原味的英文文档,但如果有官方中文文档,那么查阅或理解速度都会 ...
最新文章
- ATS 5.3.0中开启最高级别的缓存调试信息
- [Linux] 010 权限管理命令 chmod
- tftp怎么给服务器传文件,TFTP文件传输工具使用
- Kubernetes v1.16 发布 | 云原生生态周报 Vol. 20
- android gridview控件使用详解_作为Android 开发者该如何进阶?
- BIOS设置开机密码
- 分布式与人工智能课程(part4)--第四课
- [导入]ASP.NET MVC框架开发系列课程(1):MVC模式与ASP.NET MVC框架概述.zip(8.80 MB)
- 作者:曹建峰,男,腾讯研究院版权研究中心研究员,主要从事网络安全、数据保护、网络版权与内容产业等互联网法律政策研究工作。...
- springMVC下载FTP上的文件
- VB制作OCX控件的步骤
- fclose用法matlab,fclose和close之间的区别
- (附源码)php初中历史专题教学网站 毕业设计 100623
- flex属性-flex:1到底是什么
- 目录-Amira用户指南
- Linux下调整屏幕分辨率
- Node.js相关资源
- python用什么方式可以打印换行字符串_字符串是一个连续的字符序列,用________方式打印出可以换行的字符串。...
- AgentWeb使用
- 《跟着王老师学Excel VBA》的笔记
热门文章
- Call From hadoop102/192.168.10.102 to hadoop102:8020 failed on connection exception: java.net.Connec
- 【云周刊】第130期:阿里研究院发布新网商五大预测,2020年将诞生第一个机器人网商?
- python控制泰克示波器捕捉触发波形
- Dixon 检验法判断正态分布离群值——原理和 Python 实现
- Ubuntu16.04 NVIDIA显卡驱动卸载与安装
- 15.React-router6的编程式导航
- Kettle教程(三):Excel转换文本
- 自己动手写服务器-1
- Day 2: On Your Choices
- 华为鸿蒙麒麟玉兔_华为注册整本山海经?操作系统取名鸿蒙芯片取名麒麟