MoviePy - 为视频文件剪辑添加边距
在本文中,我们将了解如何在 MoviePy 中为视频文件剪辑添加边距。 MoviePy 是一个用于视频编辑的Python模块,可用于视频和 GIF 的基本操作。在排版中,页边距是页面主要内容和页面边缘之间的区域。边距有助于定义一行文本的开始和结束位置。当页面对齐时,文本会展开以与左右边距齐平,类似地,视频文件剪辑的边距会在视频和主框架之间增加额外的空间。
In order to do this we will use margin
method with the VideoFileClip object
Syntax : clip.margin(n)
Argument : It takes integer as argument
Return : It returns VideoFileClip object
下面是实现
# Import everything needed to edit video clips
from moviepy.editor import *
# loading video dsa gfg intro video
clip = VideoFileClip("dsa_geek.webm")
# getting subclip from the original video
clip = clip.subclip(0, 10)
# adding margin to the video
clip = clip.margin(40)
# showing final clip
clip.ipython_display()
输出 :
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4
Moviepy - Done !
Moviepy - video ready __temp__.mp4
另一个例子
# Import everything needed to edit video clips
from moviepy.editor import *
# loading video gfg
clip = VideoFileClip("geeks.mp4")
# getting subclip from it
clip1 = clip.subclip(0, 7)
# adding margin to the clip
clip1 = clip1.margin(20)
# showing final clip
clip1.ipython_display()
输出 :
Moviepy - Building video __temp__.mp4.
MoviePy - Writing audio in __temp__TEMP_MPY_wvf_snd.mp3
MoviePy - Done.
Moviepy - Writing video __temp__.mp4
Moviepy - Done !
Moviepy - video ready __temp__.mp4