In this article we will see how we can preview the video file clip in MoviePy. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF’s. The methods clip.show and clip.preview enable you to visualize the clip in a Pygame window. They are the fastest way to preview, as the clips are generated and displayed at the same time, and they can be useful to get the coordinates or colors of pixels. These methods require to have PyGame installed, and to use the moviepy.editor module.
In order to do this we will use
preview
method with the VideoFileClip objectSyntax : clip.preview(fps)
Argument : It takes fps as optional argument
Return : It returns None
If we click somewhere in the frames of a video clip being previewed, it will print the position and color of the pixel clicked. Press Escape abort the previewing.
Below is the implementation
# 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 ) # previewing the clip at fps = 20 clip.preview(fps = 20 ) |
Output :
Another example
# Import everything needed to edit video clips from moviepy.editor import * # loading video gfg clip = VideoFileClip( "Lazyroar.mp4" ) # getting only first 5 seconds clip = clip.subclip( 0 , 5 ) # previewing the clip at fps = 20 clip.preview(fps = 20 ) |
Output :