Video editing with Python
Call resize on mask when newsize is a function of time (#1200)
Tom Burrowse8ce135577ab
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 99c6debd..f5b2ef83 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -55,7 +55,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- `AudioFileClip` would not generate audio identical to the original file [#1108]- Several issues resulting from incorrect time values due to floating point errors [#1195], for example:- Blank frames at the end of clips [#210]- - Sometimes getting `IndexError: list index out of range` when using `concatenate_videoclips` [#646]+ - Sometimes getting `IndexError: list index out of range` when using `concatenate_videoclips` [#646]+- Applying `resize` with a non-constant `newsize` to a clip with a mask would remove the mask [#1200]## [v1.0.3](https://github.com/zulko/moviepy/tree/v1.0.3) (2020-05-07)diff --git a/moviepy/video/fx/resize.py b/moviepy/video/fx/resize.pyindex 3bdcfdcb..57f17c46 100644--- a/moviepy/video/fx/resize.py+++ b/moviepy/video/fx/resize.py@@ -98,6 +98,7 @@ def resize(clip, newsize=None, height=None, width=None, apply_to_mask=True):return nsif hasattr(newsize, "__call__"):+ # The resizing is a function of timedef newsize2(t):return trans_newsize(newsize(t))@@ -114,12 +115,15 @@ def resize(clip, newsize=None, height=None, width=None, apply_to_mask=True):def fun(gf, t):return resizer(gf(t).astype("uint8"), newsize2(t))- return clip.fl(+ newclip = clip.fl(fun, keep_duration=True, apply_to=(["mask"] if apply_to_mask else []))+ if apply_to_mask and clip.mask is not None:+ newclip.mask = resize(clip.mask, newsize, apply_to_mask=False)- else:+ return newclip+ else:newsize = trans_newsize(newsize)elif height is not None:@@ -132,7 +136,6 @@ def resize(clip, newsize=None, height=None, width=None, apply_to_mask=True):return resize(clip, fun)else:-newsize = [w * height / h, height]elif width is not None:@@ -144,7 +147,8 @@ def resize(clip, newsize=None, height=None, width=None, apply_to_mask=True):return resize(clip, fun)- newsize = [width, h * width / w]+ else:+ newsize = [width, h * width / w]# From here, the resizing is constant (not a function of time), size=newsize