Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.0 update for code & documentation #2024

Merged
merged 84 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
c3fbfe0
Unify any modification method on clip to use the with_ prefix
Jun 24, 2023
f16b197
harmonize usage of with_ for any modificating method who return a copy
Jun 25, 2023
807c6e1
Correctly import AudioArrayClip
Jun 27, 2023
77dddea
Remove dependency to imagemagick by using only imageio for gif and pi…
Jun 29, 2023
6cba8b7
Missing comma
Jun 30, 2023
5e12d7a
Remove newlines at end of string load from textfiles
Jun 30, 2023
d18ad67
Make DataVideoClip and UpdatedVideoClip part of all when importing mo…
Jul 1, 2023
692af8d
Move concatenate_videoclips from his own file to CompositeVideoClip f…
Jul 1, 2023
b18af4b
Remove the now useless script to get latest imagemagick for windows
Jul 1, 2023
dfbe066
Improve doc videoclip
Jul 5, 2023
01dedee
Remove useless param with_mask from ffmpeg_writer and directly use cl…
Jul 5, 2023
4bf4c3b
Migrate preview to ffplay instead of pygame, making pygame now useles…
Jul 5, 2023
9725733
Fix a bad indentation in audio ffmpeg reader + remove scipy and skima…
Jul 7, 2023
c18a827
Remove dependency to opencv and rewrite headblur for pure pillow
Jul 7, 2023
0f93918
Remove dependency to opencv and rewrite headblur for pure pillow
Jul 7, 2023
155167f
Remove usseless libs
Jul 7, 2023
6e4e87f
rename ffmpeg previewers to ffplay
Jul 8, 2023
d72ac0c
Change gif encoding to use modern imageio pillow and remove useless args
Jul 9, 2023
3da8b0e
Rename ipython_display to display_in_notebook
Jul 11, 2023
ec3aa84
Change doc theme to pydata
Jul 11, 2023
3545f8d
Start transition of effect from function to real class, video effects…
Jul 13, 2023
c0c2f6b
Continue transition of effect from function to method. All audio effe…
Jul 13, 2023
22ff2e2
Continue transition of effect from function to method. Transitions ar…
Jul 13, 2023
9e40c16
Finish migration of effects to class by updating auto-adding of effec…
Jul 13, 2023
f637b6a
Move from with_effect to with_effects
Jul 14, 2023
49a9023
Add shortcut for Resize, Rotate, Crop, MultiplyVolume and MultiplySpe…
Jul 15, 2023
e25729a
Fix invalid call to audio.preview instead of audio.audiopreview
Jul 18, 2023
3a2e071
Fixing improper video preview and show for composite video clip with …
Jul 20, 2023
b8553d6
Update doc
Jul 21, 2023
4f3bfbf
Remove auto adding of effects as clip methods at runtime
Jul 22, 2023
502e61b
update some doc
Jul 22, 2023
2153fd8
Refactor doc + add media for testing and doc + some polishing
Jul 25, 2023
5f57894
Validate test PR + fix subtitcles clip
Jul 25, 2023
856a7a9
Fix tests on textclip
Jul 25, 2023
ca9f48f
add doc for matmul and and operator + enforce typing of frame in clip…
Jul 25, 2023
dce5423
Fix tests on videoclip
Jul 25, 2023
27edd7b
update to laczos instead of antialias in pillow resize
Jul 26, 2023
e717320
fix test compositing
Jul 26, 2023
82b969a
update gif writer with imageio to v3 + fix gif framerate
Jul 26, 2023
50adf08
Fix tests on ffmpeg_writer
Jul 26, 2023
3bd501b
remove now useless test_examples
Jul 26, 2023
41810e2
Fix method resize + fix default expand for rotate
Jul 26, 2023
549978e
Fix bad time conversion for end_time
Jul 26, 2023
a2bcd60
add doc
Jul 26, 2023
8be5cc9
all test on fx working
Jul 26, 2023
e010536
fix tests issues
Jul 26, 2023
76993b7
fix tests on tools
Jul 26, 2023
81c2941
Use v2 imageio read for images to make gif works
Jul 26, 2023
b9d22bb
Fix videotools tests, we shall add back ipython tests later
Jul 26, 2023
35e9c7e
remove debug print + improve doc for subtitles
Jul 26, 2023
6311c4a
Fix test subtitles
Jul 26, 2023
45740d4
No need to test editor anymore
Jul 26, 2023
aa52738
Use imageio.v2 imread
Jul 27, 2023
9713a72
add param is_mask to videofileclip and auto calculate image sequence fps
Jul 27, 2023
507d173
add tests for doc examples
Jul 28, 2023
e0675c8
Use shorter media for doc testing
Jul 28, 2023
b6d4c31
Update doc code examples
Jul 28, 2023
2f6ad0d
update pre-commit, block and flake8
Jul 28, 2023
e8c50af
Make tests name for doc example more readable
Jul 28, 2023
b434d2e
fix few examples
Jul 28, 2023
59e0f8b
Apply black formatting
Jul 28, 2023
d75eb56
Use latest version of numpy
Jul 28, 2023
feda255
Fix importing version break install
Jul 28, 2023
92603ee
Remove tests with graphical interface when no gui available
Jul 29, 2023
41fdf1d
Remove tests with graphical interface when no gui available
Jul 29, 2023
82b1700
Remove tests with graphical interface when no gui available
Jul 29, 2023
73d93a2
Update Docker and the doc relative to docker usage
Jul 29, 2023
c47f334
add github link to doc menu
Jul 30, 2023
242074a
add info for migrating from v1 to v2
Jul 30, 2023
f6e467f
Remove useless test, format doc examples, add doc for dev guide, upda…
Jul 31, 2023
f72f758
add warning about breaking change with v2
Jul 31, 2023
fc6e11e
fix notice format
Jul 31, 2023
6f62c3a
change readme from rst to md
Jul 31, 2023
b95501a
improve format readme
Jul 31, 2023
d67956c
improve format readme
Jul 31, 2023
380d97b
Remove imagemagick from ci
Jul 31, 2023
ed18e81
remove old resize
Jul 31, 2023
76e948b
Rename readme.rst -> .md + fix missing line return in doc
Aug 1, 2023
218930c
Try automagical improving og doc grammar and expression through chatgpt
Aug 1, 2023
43089d4
fix title length
Aug 1, 2023
455865d
Add margin parameter to textclip
Aug 2, 2023
5241db7
Update docs/conf.py
OsaAjani Mar 6, 2024
d3aed0c
Update docs/_static/code/user_guide/compositing/juxtaposing.py
OsaAjani Mar 6, 2024
3f58b23
Add long_description_content_type
Mar 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move from with_effect to with_effects
  • Loading branch information
osaajani committed Jul 31, 2023
commit f637b6acc4d9e831338d4d3c053d05ad2b9a8d2c
15 changes: 6 additions & 9 deletions moviepy/Clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np
import proglog

from typing import Union, List, TYPE_CHECKING
from typing import List, TYPE_CHECKING

if TYPE_CHECKING:
from moviepy.Effect import Effect
Expand Down Expand Up @@ -185,18 +185,15 @@ def time_transform(self, time_func, apply_to=None, keep_duration=False):
keep_duration=keep_duration,
)

def with_effect(self, effects: Union['Effect', List['Effect']]):
def with_effects(self, effects: List['Effect']):
"""Return a copy of the current clip with the effects applied

>>> new_clip = clip.with_effect(vfx.Resize(0.2, method="bilinear"))
>>> new_clip = clip.with_effects([vfx.Resize(0.2, method="bilinear")])

You can also pass multiple effect as a list

>>> clip.with_effect([vfx.VolumeX(0.5), vfx.Resize(0.3), vfx.Mirrorx()])
>>> clip.with_effects([afx.VolumeX(0.5), vfx.Resize(0.3), vfx.Mirrorx()])
"""
if not isinstance(effects, list) :
effects = [effects]

new_clip = self.copy()
for effect in effects :
# We always copy effect before using it, see Effect.copy
Expand Down Expand Up @@ -327,7 +324,7 @@ def with_fps(self, fps, change_duration=False):
if change_duration:
from moviepy.video.fx.MultiplySpeed import MultiplySpeed

newclip = self.with_effect(MultiplySpeed(fps / self.fps))
newclip = self.with_effects(MultiplySpeed(fps / self.fps))
else:
newclip = self.copy()

Expand Down Expand Up @@ -659,4 +656,4 @@ def __mul__(self, n):

from moviepy.video.fx.Loop import Loop

return self.with_effect(Loop(n))
return self.with_effects(Loop(n))
1 change: 0 additions & 1 deletion moviepy/Effect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from abc import ABCMeta, abstractmethod
from moviepy.Clip import Clip
from dataclasses import dataclass
import copy as _copy

class Effect(metaclass=ABCMeta):
Expand Down
14 changes: 6 additions & 8 deletions moviepy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
can be directly imported like `from moviepy import VideoFileClip`.

In particular it loads all effects from the video.fx and audio.fx folders
and turns them into VideoClip and AudioClip methods, so that instead of
``clip.fx(vfx.resize, 2)`` or ``vfx.resize(clip, 2)``
you can write ``clip.resize(2)``.
and turns them into VideoClip and AudioClip methods, where method name is effect
name in snake_case preceeded by ``with_``
"""

import inspect
import copy

from moviepy.audio import fx as afx
from moviepy.audio.AudioClip import (
Expand Down Expand Up @@ -42,23 +40,23 @@

# Black magic to transforms the effects into Clip methods so that
# they can be called with clip.resize(width=500) instead of
# clip.with_effect(vfx.Resize(width=500))
# clip.with_effects([vfx.Resize(width=500)])
# We use a lot of inspect + closure + setattr + python scope magic
audio_fxs = inspect.getmembers(afx, inspect.isclass)
video_fxs = inspect.getmembers(vfx, inspect.isclass) + audio_fxs

def add_effect_as_method(to_klass, method_name, eklass) :
def effect_call(clip, *args, **kwargs):
return clip.with_effect(eklass(*args, **kwargs).copy())
return clip.with_effects([eklass(*args, **kwargs).copy()])

setattr(to_klass, method_name, effect_call)

for name, effect_class in video_fxs :
camel_name = re.sub('(?!^)([A-Z]+)', r'_\1', name).lower()
camel_name = 'with_' + re.sub('(?!^)([A-Z]+)', r'_\1', name).lower()
add_effect_as_method(VideoClip, camel_name, effect_class)

for name, effect_class in audio_fxs :
camel_name = re.sub('(?!^)([A-Z]+)', r'_\1', name).lower()
camel_name = 'with_' + re.sub('(?!^)([A-Z]+)', r'_\1', name).lower()
add_effect_as_method(AudioClip, camel_name, effect_class)

# Add display in notebook to video and audioclip
Expand Down
8 changes: 4 additions & 4 deletions moviepy/audio/fx/AudioDelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ class AudioDelay(Effect) :
--------

>>> from moviepy import *
>>> videoclip = AudioFileClip('myaudio.wav').with_effect(
>>> videoclip = AudioFileClip('myaudio.wav').with_effects([
... afx.AudioDelay(offset=.2, n_repeats=10, decayment=.2)
... )
... ])

>>> # stereo A note
>>> make_frame = lambda t: np.array(
... [np.sin(440 * 2 * np.pi * t), np.sin(880 * 2 * np.pi * t)]
... ).T
... clip = AudioClip(make_frame=make_frame, duration=0.1, fps=44100)
... clip = clip.with_effect(afx.AudioDelay(offset=.2, n_repeats=11, decay=0))
... clip = clip.with_effects([afx.AudioDelay(offset=.2, n_repeats=11, decay=0)])
"""

offset: float = 0.2
Expand All @@ -57,7 +57,7 @@ def apply(self, clip: Clip) -> Clip:
[
clip.copy(),
*[
clip.with_start((rep + 1) * self.offset).with_effect(MultiplyVolume(decayments[rep + 1]))
clip.with_start((rep + 1) * self.offset).with_effects([MultiplyVolume(decayments[rep + 1])])
for rep in range(self.n_repeats)
],
]
Expand Down
2 changes: 1 addition & 1 deletion moviepy/audio/fx/AudioFadeIn.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AudioFadeIn(Effect) :
--------

>>> clip = VideoFileClip("media/chaplin.mp4")
>>> clip.with_effect(AudioFadeIn("00:00:06"))
>>> clip.with_effects([vfx.AudioFadeIn("00:00:06")])
"""

duration: float
Expand Down
2 changes: 1 addition & 1 deletion moviepy/audio/fx/AudioFadeOut.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AudioFadeOut(Effect) :
--------

>>> clip = VideoFileClip("media/chaplin.mp4")
>>> clip.with_effect(afx.AudioFadeOut("00:00:06"))
>>> clip.with_effects([afx.AudioFadeOut("00:00:06")])
"""

duration: float
Expand Down
2 changes: 1 addition & 1 deletion moviepy/audio/fx/AudioLoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AudioLoop(Effect) :
>>> from moviepy import *
>>> videoclip = VideoFileClip('myvideo.mp4')
>>> music = AudioFileClip('music.ogg')
>>> audio = music.with_effect(afx.AudioLoop(duration=videoclip.duration))
>>> audio = music.with_effects([afx.AudioLoop(duration=videoclip.duration)])
>>> videoclip.with_audio(audio)

"""
Expand Down
4 changes: 2 additions & 2 deletions moviepy/audio/fx/AudioNormalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AudioNormalize(Effect) :
--------

>>> from moviepy import *
>>> videoclip = VideoFileClip('myvideo.mp4').with_effect(afx.AudioNormalize())
>>> videoclip = VideoFileClip('myvideo.mp4').with_effects([afx.AudioNormalize()])

"""

Expand All @@ -26,4 +26,4 @@ def apply(self, clip: Clip) -> Clip:
if max_volume == 0:
return clip
else:
return clip.with_effect(MultiplyVolume(1 / max_volume))
return clip.with_effects(MultiplyVolume(1 / max_volume))
4 changes: 2 additions & 2 deletions moviepy/audio/fx/MultiplyStereoVolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class MultiplyStereoVolume(Effect) :

>>> from moviepy import AudioFileClip
>>> music = AudioFileClip('music.ogg')
>>> audio_r = music.with_effect(afx.MultiplyStereoVolume(left=0, right=1)) # mute left channel/s
>>> audio_h = music.with_effect(afx.MultiplyStereoVolume(left=0.5, right=0.5))) # half audio
>>> audio_r = music.with_effects([afx.MultiplyStereoVolume(left=0, right=1)]) # mute left channel/s
>>> audio_h = music.with_effects([afx.MultiplyStereoVolume(left=0.5, right=0.5)]) # half audio
"""

left: float = 1
Expand Down
6 changes: 3 additions & 3 deletions moviepy/audio/fx/MultiplyVolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class MultiplyVolume(Effect) :
>>> from moviepy import AudioFileClip
>>>
>>> music = AudioFileClip('music.ogg')
>>> doubled_audio_clip = clip.with_effect(MultiplyVolume(2)) # doubles audio volume
>>> half_audio_clip = clip.with_effect(MultiplyVolume(0.5)) # half audio
>>> doubled_audio_clip = clip.with_effects([afx.MultiplyVolume(2)]) # doubles audio volume
>>> half_audio_clip = clip.with_effects([afx.MultiplyVolume(0.5)]) # half audio
>>>
>>> # silenced clip during one second at third
>>> silenced_clip = clip.with_effect(MultiplyVolume(0, start_time=2, end_time=3))
>>> silenced_clip = clip.with_effects([afx.MultiplyVolume(0, start_time=2, end_time=3)])
"""

factor: float
Expand Down
16 changes: 0 additions & 16 deletions moviepy/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,6 @@ def audio_video_effect(func, effect, clip, *args, **kwargs):
return clip
else:
return func(effect, clip, *args, **kwargs)

@decorator.decorator
def audio_video_fx(func, clip, *args, **kwargs):
"""Use an audio function on a video/audio clip.

This decorator tells that the function func (audioclip -> audioclip)
can be also used on a video clip, at which case it returns a
videoclip with unmodified video and modified audio.
"""
if hasattr(clip, "audio"):
new_clip = clip.copy()
if clip.audio is not None:
new_clip.audio = func(clip.audio, *args, **kwargs)
return new_clip
else:
return func(clip, *args, **kwargs)


def preprocess_args(fun, varnames):
Expand Down
14 changes: 9 additions & 5 deletions moviepy/video/VideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
import threading
from moviepy.video.io.ffplay_previewer import ffplay_preview_video

from typing import List
from typing import Union, List, TYPE_CHECKING

if TYPE_CHECKING:
from moviepy.Effect import Effect

from moviepy.Clip import Clip
from moviepy.decorators import (
Expand Down Expand Up @@ -618,7 +621,7 @@ def preview(
# -----------------------------------------------------------------
# F I L T E R I N G

def subfx(self, fx, start_time=0, end_time=None, **kwargs):
def with_sub_effect(self, effects: List['Effect'], start_time=0, end_time=None, **kwargs):
"""Apply a transformation to a part of the clip.

Returns a new clip in which the function ``fun`` (clip->clip)
Expand All @@ -630,11 +633,11 @@ def subfx(self, fx, start_time=0, end_time=None, **kwargs):

>>> # The scene between times t=3s and t=6s in ``clip`` will be
>>> # be played twice slower in ``new_clip``
>>> new_clip = clip.subapply(lambda c:c.multiply_speed(0.5) , 3,6)
>>> new_clip = clip.with_sub_effect(MultiplySpeed(0.5), 3, 6)

"""
left = None if (start_time == 0) else self.with_subclip(0, start_time)
center = self.with_subclip(start_time, end_time).fx(fx, **kwargs)
center = self.with_subclip(start_time, end_time).with_effects(effects, **kwargs)
right = None if (end_time is None) else self.with_subclip(start_time=end_time)

clips = [clip for clip in [left, center, right] if clip is not None]
Expand All @@ -644,6 +647,7 @@ def subfx(self, fx, start_time=0, end_time=None, **kwargs):

return concatenate_videoclips(clips).with_start(self.start)


# IMAGE FILTERS

def image_transform(self, image_func, apply_to=None):
Expand Down Expand Up @@ -993,7 +997,7 @@ def __matmul__(self, n):
return NotImplemented

from moviepy.video.fx.Rotate import Rotate
return self.with_effect(Rotate(n))
return self.with_effects(Rotate(n))

def __and__(self, mask):
return self.with_mask(mask)
Expand Down
2 changes: 1 addition & 1 deletion moviepy/video/fx/CrossFadeIn.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def apply(self, clip: Clip) -> Clip:
clip = clip.with_add_mask()

clip.mask.duration = clip.duration
clip.mask = clip.mask.with_effect(FadeIn(self.duration))
clip.mask = clip.mask.with_effects([FadeIn(self.duration)])

return clip

2 changes: 1 addition & 1 deletion moviepy/video/fx/CrossFadeOut.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def apply(self, clip: Clip) -> Clip:
clip = clip.with_add_mask()

clip.mask.duration = clip.duration
clip.mask = clip.mask.with_effect(FadeOut(self.duration))
clip.mask = clip.mask.with_effects([FadeOut(self.duration)])

return clip

4 changes: 2 additions & 2 deletions moviepy/video/fx/FreezeRegion.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def apply(self, clip: Clip) -> Clip:
if self.region is not None:
x1, y1, x2, y2 = self.region
freeze = (
clip.with_effect(Crop(*self.region))
clip.with_effects(Crop(*self.region))
.to_ImageClip(t=self.t)
.with_duration(clip.duration)
.with_position((x1, y1))
Expand All @@ -51,7 +51,7 @@ def apply(self, clip: Clip) -> Clip:

elif self.outside_region is not None:
x1, y1, x2, y2 = self.outside_region
animated_region = clip.with_effect(Crop(*self.outside_region)).with_position((x1, y1))
animated_region = clip.with_effects(Crop(*self.outside_region)).with_position((x1, y1))
freeze = clip.to_ImageClip(t=self.t).with_duration(clip.duration)
return CompositeVideoClip([freeze, animated_region])

Expand Down
6 changes: 3 additions & 3 deletions moviepy/video/fx/MasksAnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class MasksAnd(Effect) :
Examples
--------

>>> clip = ColorClip(color=(255, 0, 0), size=(1, 1)) # red
>>> mask = ColorClip(color=(0, 255, 0), size=(1, 1)) # green
>>> masked_clip = clip.fx(mask_and, mask) # black
>>> clip = ColorClip(color=(255, 0, 0), size=(1, 1)) # red
>>> mask = ColorClip(color=(0, 255, 0), size=(1, 1)) # green
>>> masked_clip = clip.with_effects([vfx.MasksAnd(mask)]) # black
>>> masked_clip.get_frame(0)
[[[0 0 0]]]
"""
Expand Down
6 changes: 3 additions & 3 deletions moviepy/video/fx/MasksOr.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class MasksOr(Effect) :
Examples
--------

>>> clip = ColorClip(color=(255, 0, 0), size=(1, 1)) # red
>>> mask = ColorClip(color=(0, 255, 0), size=(1, 1)) # green
>>> masked_clip = clip.fx(mask_or, mask) # yellow
>>> clip = ColorClip(color=(255, 0, 0), size=(1, 1)) # red
>>> mask = ColorClip(color=(0, 255, 0), size=(1, 1)) # green
>>> masked_clip = clip.with_effects([vfx.MasksOr(mask)]) # yellow
>>> masked_clip.get_frame(0)
[[[255 255 0]]]
"""
Expand Down
16 changes: 8 additions & 8 deletions moviepy/video/fx/Resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def __init__(self, new_size=None, height=None, width=None, apply_to_mask=True) :
Examples
--------

>>> myClip.with_effect(vfx.Resize((460,720))) # New resolution: (460,720)
>>> myClip.with_effect(vfx.Resize(0.6)) # width and height multiplied by 0.6
>>> myClip.with_effect(vfx.Resize(width=800)) # height computed automatically.
>>> myClip.with_effect(vfx.Resize(lambda t : 1+0.02*t)) # slow swelling of the clip
>>> myClip.with_effects([vfx.Resize((460,720))]) # New resolution: (460,720)
>>> myClip.with_effects([vfx.Resize(0.6)]) # width and height multiplied by 0.6
>>> myClip.with_effects([vfx.Resize(width=800)]) # height computed automatically.
>>> myClip.with_effects([vfx.Resize(lambda t : 1+0.02*t)]) # slow swelling of the clip
"""
self.new_size = new_size
self.height = height
Expand Down Expand Up @@ -83,7 +83,7 @@ def filter(get_frame, t):
filter, keep_duration=True, apply_to=(["mask"] if self.apply_to_mask else [])
)
if self.apply_to_mask and clip.mask is not None:
newclip.mask = newclip.mask.with_effect(Resize(clip.mask, self.new_size, apply_to_mask=False))
newclip.mask = newclip.mask.with_effects([Resize(clip.mask, self.new_size, apply_to_mask=False)])

return newclip

Expand All @@ -96,7 +96,7 @@ def filter(get_frame, t):
def func(t):
return 1.0 * int(self.height(t)) / h

return clip.with_effect(Resize(func))
return clip.with_effects(Resize(func))

else:
new_size = [w * self.height / h, self.height]
Expand All @@ -107,7 +107,7 @@ def func(t):
def func(t):
return 1.0 * self.width(t) / w

return clip.with_effect(Resize(func))
return clip.with_effects(Resize(func))

else:
new_size = [self.width, h * self.width / w]
Expand All @@ -128,6 +128,6 @@ def image_filter(pic):
new_clip = clip.image_transform(image_filter)

if self.apply_to_mask and clip.mask is not None:
new_clip.mask = clip.with_effect(Resize(clip.mask, self.new_size, apply_to_mask=False))
new_clip.mask = clip.with_effects(Resize(clip.mask, self.new_size, apply_to_mask=False))

return new_clip
4 changes: 2 additions & 2 deletions moviepy/video/fx/SlideIn.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ class SlideIn(Effect):
>>>
>>> clips = [... make a list of clips]
>>> slided_clips = [
... CompositeVideoClip([clip.with_effect(vfx.SlideIn(1, "left"))])
... CompositeVideoClip([clip.with_effects([vfx.SlideIn(1, "left")])])
... for clip in clips
... ]
>>> final_clip = concatenate_videoclips(slided_clips, padding=-1)
>>>
>>> clip = ColorClip(
... color=(255, 0, 0), duration=1, size=(300, 300)
... ).with_fps(60)
>>> final_clip = CompositeVideoClip([clip.with_effect(vfx.SlideIn(1, "right"))])
>>> final_clip = CompositeVideoClip([clip.with_effects([vfx.SlideIn(1, "right")])])
"""

duration: float
Expand Down
Loading