📜  MoviePy – 显示一帧视频剪辑

📅  最后修改于: 2022-05-13 01:55:47.532000             🧑  作者: Mango

MoviePy – 显示一帧视频剪辑

在本文中,我们将了解如何在 MoviePy 中显示视频文件剪辑的给定时间的单帧。 MoviePy 是一个用于视频编辑的Python模块,可用于视频和 GIF 的基本操作。视频是由帧组成的,帧的组合创建一个视频,每一帧都是一个单独的图像。我们可以在 VideoFileClip 对象的 save_frame 方法的帮助下随时存储特定帧。

方法 clip.show 可以预览剪辑的一帧,而无需将其写入文件:以下行在 PyGame 窗口中显示该帧

下面是实现

Python3
# Import everything needed to edit video clips
from moviepy.editor import *
 
  
# loading video dsa gfg intro video
clip = VideoFileClip("dsa_geek.webm")
  
# getting only first 5 seconds
clip = clip.subclip(0, 5)
 
# showing frame at 2 second
clip.show(2)


Python3
# Import everything needed to edit video clips
from moviepy.editor import *
 
# loading video gfg
clip = VideoFileClip("geeks.mp4")
 
 
# getting duration of the video
duration = clip.duration
 
# showing frame at 3 second
clip.show(3)


输出 :

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 duration of the video
duration = clip.duration
 
# showing frame at 3 second
clip.show(3)

输出 :

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