moviepy.video.io.VideoFileClip.VideoFileClip#
- class moviepy.video.io.VideoFileClip.VideoFileClip(filename, decode_file=False, has_mask=False, audio=True, audio_buffersize=200000, target_resolution=None, resize_algorithm='bicubic', audio_fps=44100, audio_nbytes=2, fps_source='fps', pixel_format=None, is_mask=False)[source]#
A video clip originating from a movie file. For instance:
clip = VideoFileClip("myHolidays.mp4") clip.close() with VideoFileClip("myMaskVideo.avi") as clip2: pass # Implicit close called by context manager.
- Parameters:
filename -- The name of the video file, as a string or a path-like object. It can have any extension supported by ffmpeg: .ogv, .mp4, .mpeg, .avi, .mov etc.
has_mask -- Set this to 'True' if there is a mask included in the videofile. Video files rarely contain masks, but some video codecs enable that. For instance if you have a MoviePy VideoClip with a mask you can save it to a videofile with a mask. (see also
VideoClip.write_videofilefor more details).audio -- Set to False if the clip doesn't have any audio or if you do not wish to read the audio.
target_resolution -- Set to (desired_width, desired_height) to have ffmpeg resize the frames before returning them. This is much faster than streaming in high-res and then resizing. If either dimension is None, the frames are resized by keeping the existing aspect ratio.
resize_algorithm -- The algorithm used for resizing. Default: "bicubic", other popular options include "bilinear" and "fast_bilinear". For more information, see https://ffmpeg.org/ffmpeg-scaler.html
fps_source -- The fps value to collect from the metadata. Set by default to 'fps', but can be set to 'tbr', which may be helpful if you are finding that it is reading the incorrect fps from the file.
pixel_format -- Optional: Pixel format for the video to read. If is not specified 'rgb24' will be used as the default format unless
has_maskis set asTrue, then 'rgba' will be used.is_mask -- True if the clip is going to be used as a mask.
- filename#
Name of the original video file.
- fps#
Frames per second in the original file.
Read docs for Clip() and VideoClip() for other, more generic, attributes.
Lifetime#
Note that this creates subprocesses and locks files. If you construct one of these instances, you must call close() afterwards, or the subresources will not be cleaned up until the process ends.
If copies are made, and close() is called on one, it may cause methods on the other copies to fail.