MoviePy - 显示视频文件剪辑
在本文中,我们将了解如何在 MoviePy 中显示视频文件剪辑。 MoviePy 是一个用于视频编辑的Python模块,可用于视频和 GIF 的基本操作。将一系列图像组合成运动图片的视觉多媒体源。视频将信号传输到屏幕并处理应显示屏幕截图的顺序。视频通常具有与屏幕上显示的图片相对应的音频组件。
In order to do this we will use ipython_display
method with the VideoFileClip object
Syntax : clip.ipython_display(width, height)
Argument : It takes two optional arguments i.e integers
Return : It returns HTML2 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(0, 10)
# showing clip
clip.ipython_display(width = 280, height = 320)
输出 :
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")
# 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__.mp4