MoviePy - 创建图像序列剪辑
在本文中,我们将了解如何在 MoviePy 中创建图像序列剪辑。 MoviePy 是一个用于视频编辑的Python模块,可用于视频和 GIF 的基本操作。视频是由帧组成的,帧的组合创建一个视频,每一帧都是一个单独的图像。图像序列剪辑是通过将图像逐一组合形成序列即视频而形成的剪辑。
In order to do this we will use ImageSequenceClip
method
Syntax : ImageSequenceClip([‘image_file1.jpeg’, …], fps=24)
Argument : It takes image file names and fps as argument
Return : It returns ImageSequenceClip object
下面是实现
# importing editor from movie py
from moviepy.editor import *
# creating a Image sequence clip with fps = 1
clip = ImageSequenceClip(['frame1.png', 'frame2.png', 'frame1.png', 'frame2.png'], fps = 1)
# showing clip
clip.ipython_display(width = 360)
输出 :
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4
Moviepy - Done !
Moviepy - video ready __temp__.mp4
另一个例子
# importing editor from movie py
from moviepy.editor import *
# creating a Image sequence clip with fps = 3
clip = ImageSequenceClip(['frame1.png', 'frame1.png', 'frame2.png',
'frame1.png', 'frame1.png', 'frame2.png',
'frame1.png', 'frame1.png', 'frame2.png'], fps = 3)
# showing clip
clip.ipython_display(width = 360)
输出 :
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4
Moviepy - Done !
Moviepy - video ready __temp__.mp4