MoviePy – 获取子剪辑
在本文中,我们将了解如何在 MoviePy 中显示视频文件剪辑。 MoviePy 是一个用于视频编辑的Python模块,可用于视频和 GIF 的基本操作。子剪辑是您要在项目中单独编辑和管理的主(源)剪辑的一部分。您可以使用子剪辑来组织长媒体文件。您可以在“时间轴”面板中使用子剪辑,就像使用主剪辑一样。修剪和编辑子剪辑受其起点和终点的约束。剪辑有助于克服一次显示大视频时发生的内存错误。
In order to do this we will use subclip
method with the VideoFileClip object
Syntax : clip.subclip(i, j)
Argument : It takes two integer argument which are starting and ending value in seconds
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 as video is large
clip = clip.subclip(55, 65)
# showing clip
clip.ipython_display(width = 480)
输出 :
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
clip = clip.subclip(0, 7)
# showing clip
clip.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__.mp