MoviePy – Getting frame from Video File Clip
In this article we will see how we can get the frame at given time from 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. Combination of frames make the video, at each time there exist a specific frame which is similar to normal image.Getting frame means to get a numpy array representing the RGB picture of the clip at time t or (mono or stereo) value for a sound clip.
In order to do this we will use get_frame
method with the VideoFileClip object
Syntax : clip.get_frame(n)
Argument : It takes float value as argument
Return : It returns numpy ndarray
Below is the implementation
from matplotlib import pyplot as plt
import numpy as np
from moviepy.editor import *
clip = VideoFileClip( "geeks.mp4" )
clip = clip.subclip( 0 , 5 )
clip = clip.subclip( 0 , 5 )
frame = clip.get_frame( 3 )
plt.imshow(frame, interpolation = 'nearest' )
plt.show()
|
Output :
Another example
from matplotlib import pyplot as plt
import numpy as np
from moviepy.editor import *
clip = VideoFileClip( "dsa_geek.mp4" )
clip = clip.subclip( 0 , 5 )
frame = clip.get_frame( 2 )
plt.imshow(frame, interpolation = 'nearest' )
plt.show()
|
Output :
Last Updated :
30 Aug, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...