Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Zulko committed Nov 23, 2024
1 parent 9fd857d commit 304fc50
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/_static/code/user_guide/loading/masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import numpy as np

# Random RGB noise image of 200x100
makeframe = lambda t: np.random.rand(100, 200)
frame_function = lambda t: np.random.rand(100, 200)

# To define the VideoClip as a mask, just pass parameter is_mask as True
maskclip1 = VideoClip(makeframe, duration=4, is_mask=True) # A random noise mask
maskclip1 = VideoClip(frame_function, duration=4, is_mask=True) # A random noise mask
maskclip2 = ImageClip("example_mask.jpg", is_mask=True) # A fixed mask as jpeg
maskclip3 = VideoFileClip("example_mask.mp4", is_mask=True) # A video as a mask

Expand Down
4 changes: 2 additions & 2 deletions moviepy/video/VideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,15 +850,15 @@ def with_mask(self, mask: Union["VideoClip", str] = "auto"):
Returns a copy of the VideoClip with the mask attribute set to
``mask``, which must be a greyscale (values in 0-1) VideoClip.
"""
if mask == "auto":
if mask == "auto":
if self.has_constant_size:
mask = ColorClip(self.size, 1.0, is_mask=True)
return self.with_mask(mask.with_duration(self.duration))
else:
def frame_function(t):
return np.ones(self.get_frame(t).shape[:2], dtype=float)

mask = VideoClip(is_mask=True, frame_function=frame_function)
mask = VideoClip(is_mask=True, frame_function=frame_function)
self.mask = mask

@outplace
Expand Down

0 comments on commit 304fc50

Please sign in to comment.