Related Articles

Related Articles

MoviePy – Previewing a Video Clip
  • Last Updated : 01 Aug, 2020

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 vizualise 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 object

Syntax : 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

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output :

Another example

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)
  
  
# previewing the clip at fps = 20
clip.preview(fps = 20)

chevron_right


Output :

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :