MoviePy - 浅拷贝视频文件剪辑
在本文中,我们将了解如何在 MoviePy 中浅拷贝视频文件剪辑。 MoviePy 是一个用于视频编辑的Python模块,可用于视频和 GIF 的基本操作。浅拷贝是对象的按位拷贝。创建一个新对象,该对象具有原始对象中值的精确副本。如果对象的任何字段是对其他对象的引用,则仅复制引用地址,即仅复制内存地址。每次剪辑发生替换转换(clip.resize、clip.subclip 等)时,浅拷贝被集中用于生成新剪辑
In order to do this we will use copy
method with the VideoFileClip object
Syntax : clip.copy()
Argument : It takes no argument
Return : It returns VideoFileClip
下面是实现
# Import everything needed to edit video clips
from moviepy.editor import *
# loading video dsa gfg intro video
clip = VideoFileClip("dsa_geek.mp4")
# getting only first 5 seconds
clip = clip.subclip(0, 5)
# shallow copy the given clip
copied_clip = clip.copy()
# showing clip
copied_clip.ipython_display(width = 360)
输出 :
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 only first 5 seconds
clip = clip.subclip(0, 5)
# shallow copy the given clip
copied_clip = clip.copy()
# showing clip
copied_clip.ipython_display(width = 360)
输出 :
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4
Moviepy - Done !
Moviepy - video ready __temp__.mp4