moviepy.video.fx.Crop#

class moviepy.video.fx.Crop.Crop(x1: int = None, y1: int = None, x2: int = None, y2: int = None, width: int = None, height: int = None, x_center: int = None, y_center: int = None)[source]#

Effect to crop a clip to get a new clip in which just a rectangular subregion of the original clip is conserved. x1,y1 indicates the top left corner and x2,y2 is the lower right corner of the cropped region. All coordinates are in pixels. Float numbers are accepted.

To crop an arbitrary rectangle:

>>> Crop(x1=50, y1=60, x2=460, y2=275)

Only remove the part above y=30:

>>> Crop(y1=30)

Crop a rectangle that starts 10 pixels left and is 200px wide

>>> Crop(x1=10, width=200)

Crop a rectangle centered in x,y=(300,400), width=50, height=150 :

>>> Crop(x_center=300, y_center=400, width=50, height=150)

Any combination of the above should work, like for this rectangle centered in x=300, with explicit y-boundaries:

>>> Crop(x_center=300, width=400, y1=100, y2=600)
apply(clip: Clip) Clip[source]#

Apply the effect to the clip.

copy()#

Return a shallow copy of an Effect.

You must always copy an Effect before applying, because some of them will modify their own attributes when applied. For example, setting a previously unset property by using target clip property.

If we was to use the original effect, calling the same effect multiple times could lead to different properties, and different results for equivalent clips.

By using copy, we ensure we can use the same effect object multiple times while maintaining the same behavior/result.

In a way, copy makes the effect himself being kind of idempotent.