Skip to content

Video editing with Python

add param is_mask to videofileclip and auto calculate image sequence fps

osaajani9713a7229639
diff --git a/moviepy/video/io/ImageSequenceClip.py b/moviepy/video/io/ImageSequenceClip.py
index 48f3ee38..ba308314 100644
--- a/moviepy/video/io/ImageSequenceClip.py
+++ b/moviepy/video/io/ImageSequenceClip.py
@@ -109,6 +109,9 @@ class ImageSequenceClip(VideoClip):
self.end = self.duration
self.sequence = sequence
+ if fps is None:
+ self.fps = self.duration / len(sequence)
+
def find_image_index(t):
return max(
[i for i in range(len(self.sequence)) if self.images_starts[i] <= t]
diff --git a/moviepy/video/io/VideoFileClip.py b/moviepy/video/io/VideoFileClip.py
index f18cff61..1f41f4ee 100644
--- a/moviepy/video/io/VideoFileClip.py
+++ b/moviepy/video/io/VideoFileClip.py
@@ -56,6 +56,9 @@ class VideoFileClip(VideoClip):
'rgb24' will be used as the default format unless ``has_mask`` is set
as ``True``, then 'rgba' will be used.
+ is_mask
+ `True` if the clip is going to be used as a mask.
+
Attributes
----------
@@ -95,8 +98,9 @@ class VideoFileClip(VideoClip):
audio_nbytes=2,
fps_source="fps",
pixel_format=None,
+ is_mask=False,
):
- VideoClip.__init__(self)
+ VideoClip.__init__(self, is_mask=is_mask)
# Make a reader
if not pixel_format: