diff --git a/moviepy/Clip.py b/moviepy/Clip.py index fbab136af..efdfb22c6 100644 --- a/moviepy/Clip.py +++ b/moviepy/Clip.py @@ -94,7 +94,7 @@ def get_frame(self, t): else: return self.make_frame(t) - def fl(self, fun, apply_to=[], keep_duration=True): + def fl(self, fun, apply_to=None, keep_duration=True): """ General processing of a clip. Returns a new Clip whose frames are a transformation @@ -131,6 +131,8 @@ def fl(self, fun, apply_to=[], keep_duration=True): >>> newclip = clip.fl(fl, apply_to='mask') """ + if apply_to is None: + apply_to = [] #mf = copy(self.make_frame) newclip = self.set_make_frame(lambda t: fun(self.get_frame, t)) @@ -153,7 +155,7 @@ def fl(self, fun, apply_to=[], keep_duration=True): - def fl_time(self, t_func, apply_to=[], keep_duration=False): + def fl_time(self, t_func, apply_to=None, keep_duration=False): """ Returns a Clip instance playing the content of the current clip but with a modified timeline, time ``t`` being replaced by another @@ -184,6 +186,8 @@ def fl_time(self, t_func, apply_to=[], keep_duration=False): >>> newclip = clip.fl_time(lambda: 3-t) """ + if apply_to is None: + apply_to = [] return self.fl(lambda gf, t: gf(t_func(t)), apply_to, keep_duration=keep_duration) diff --git a/moviepy/config.py b/moviepy/config.py index 307abf901..e102253f8 100644 --- a/moviepy/config.py +++ b/moviepy/config.py @@ -80,8 +80,10 @@ def get_setting(varname): return gl[varname] -def change_settings(new_settings={}, file=None): +def change_settings(new_settings=None, file=None): """ Changes the value of configuration variables.""" + if new_settings is None: + new_settings = {} gl = globals() if file is not None: execfile(file) diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py index b1c9089d7..28caf7d19 100644 --- a/moviepy/video/VideoClip.py +++ b/moviepy/video/VideoClip.py @@ -489,11 +489,13 @@ def subfx(self, fx, ta=0, tb=None, **kwargs): # IMAGE FILTERS - def fl_image(self, image_func, apply_to=[]): + def fl_image(self, image_func, apply_to=None): """ Modifies the images of a clip by replacing the frame `get_frame(t)` by another frame, `image_func(get_frame(t))` """ + if apply_to is None: + apply_to = [] return self.fl(lambda gf, t: image_func(gf(t)), apply_to) # -------------------------------------------------------------- @@ -918,12 +920,14 @@ def __init__(self, img, ismask=False, transparent=True, self.size = img.shape[:2][::-1] self.img = img - def fl(self, fl, apply_to=[], keep_duration=True): + def fl(self, fl, apply_to=None, keep_duration=True): """General transformation filter. Equivalent to VideoClip.fl . The result is no more an ImageClip, it has the class VideoClip (since it may be animated) """ + if apply_to is None: + apply_to = [] # When we use fl on an image clip it may become animated. # Therefore the result is not an ImageClip, just a VideoClip. newclip = VideoClip.fl(self, fl, apply_to=apply_to, @@ -932,13 +936,15 @@ def fl(self, fl, apply_to=[], keep_duration=True): return newclip @outplace - def fl_image(self, image_func, apply_to=[]): + def fl_image(self, image_func, apply_to=None): """Image-transformation filter. Does the same as VideoClip.fl_image, but for ImageClip the tranformed clip is computed once and for all at the beginning, and not for each 'frame'. """ + if apply_to is None: + apply_to = [] arr = image_func(self.get_frame(0)) self.size = arr.shape[:2][::-1] self.make_frame = lambda t: arr @@ -952,7 +958,7 @@ def fl_image(self, image_func, apply_to=[]): setattr(self, attr, new_a) @outplace - def fl_time(self, time_func, apply_to=['mask', 'audio'], + def fl_time(self, time_func, apply_to=None, keep_duration=False): """Time-transformation filter. @@ -962,6 +968,8 @@ def fl_time(self, time_func, apply_to=['mask', 'audio'], This method does nothing for ImageClips (but it may affect their masks or their audios). The result is still an ImageClip. """ + if apply_to is None: + apply_to = ['mask', 'audio'] for attr in apply_to: if hasattr(self, attr): a = getattr(self, attr) diff --git a/moviepy/video/fx/blackwhite.py b/moviepy/video/fx/blackwhite.py index 5d4f12399..140c649c6 100644 --- a/moviepy/video/fx/blackwhite.py +++ b/moviepy/video/fx/blackwhite.py @@ -1,11 +1,13 @@ import numpy as np -def blackwhite(clip, RGB = [1,1,1], preserve_luminosity=True): +def blackwhite(clip, RGB = None, preserve_luminosity=True): """ Desaturates the picture, makes it black and white. Parameter RGB allows to set weights for the different color channels. If RBG is 'CRT_phosphor' a special set of values is used. preserve_luminosity maintains the sum of RGB to 1.""" + if RGB is None: + RGB = [1,1,1] if RGB == 'CRT_phosphor': RGB = [0.2125, 0.7154, 0.0721] diff --git a/moviepy/video/fx/mask_color.py b/moviepy/video/fx/mask_color.py index 8cd302365..b5c102d88 100644 --- a/moviepy/video/fx/mask_color.py +++ b/moviepy/video/fx/mask_color.py @@ -1,6 +1,6 @@ import numpy as np -def mask_color(clip, color=[0,0,0], thr=0, s=1): +def mask_color(clip, color=None, thr=0, s=1): """ Returns a new clip with a mask for transparency where the original clip is of the given color. @@ -12,6 +12,8 @@ def mask_color(clip, color=[0,0,0], thr=0, s=1): which is 1 when d>>thr and 0 for d<