MoviePy - 从视频文件剪辑中删除
在本文中,我们将了解如何在 MoviePy 中截取视频文件剪辑。 MoviePy 是一个用于视频编辑的Python模块,可用于视频和 GIF 的基本操作。剪切视频是修剪后的视频,或者我们可以说它从原始视频中剪切了几秒钟,它用于跳过视频的某些部分。剪切意味着从原始视频中获取视频,并在视频之间跳过一段时间。
In order to do this we will use cutout method with the VideoFileClip object
Syntax : clip.cutout(ts, te)
Argument : It takes two integer as argument (start and end time to skip)
Return : It returns VideoFileClip
下面是实现
Python3
# 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, 15)
# cutting out some part from the clip
clip = clip.cutout(3, 10)
# showing clip
clip.ipython_display(width = 360)
Python3
# 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)
# getting only first 5 seconds
clip = clip.subclip(0, 10)
# cutting out some part from the clip
clip = clip.cutout(3, 7)
# showing clip
clip.ipython_display(width = 360)
输出 :
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4
Moviepy - Done !
Moviepy - video ready __temp__.mp4
另一个例子
Python3
# 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)
# getting only first 5 seconds
clip = clip.subclip(0, 10)
# cutting out some part from the clip
clip = clip.cutout(3, 7)
# showing clip
clip.ipython_display(width = 360)
输出 :
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