Skip to content

Video editing with Python

More api changes (#2255)

Zulkob22e70293438
diff --git a/.github/workflows/formatting_linting.yml b/.github/workflows/formatting_linting.yml
index 4de0e259..a8bd0c14 100644
--- a/.github/workflows/formatting_linting.yml
+++ b/.github/workflows/formatting_linting.yml
@@ -47,7 +47,7 @@ jobs:
- name: Show Flake8 version
run: flake8 --version
- name: Run Flake8
- run: flake8 -v --show-source moviepy docs/conf.py examples tests
+ run: flake8 -v --show-source --max-line-length=92 moviepy docs/conf.py examples tests
isort:
name: isort import sorter
diff --git a/README.md b/README.md
index de2b2f75..2db51c8a 100644
--- a/README.md
+++ b/README.md
@@ -24,10 +24,10 @@ result to a new file:
from moviepy import *
# Load file example.mp4 and keep only the subclip from 00:00:10 to 00:00:20
-clip = VideoFileClip("long_examples/example2.mp4").with_subclip(10, 20)
+clip = VideoFileClip("long_examples/example2.mp4").subclipped(10, 20)
# Reduce the audio volume to 80% of its original volume
-clip = clip.with_multiply_volume(0.8)
+clip = clip.with_volume_scaled(0.8)
# Generate a text clip. You can customize the font, color, etc.
txt_clip = TextClip(font="example.ttf", text="Big Buck Bunny", font_size=70, color='white')
diff --git a/docs/_static/code/getting_started/moviepy_10_minutes/trailer.py b/docs/_static/code/getting_started/moviepy_10_minutes/trailer.py
index f530c383..a914f895 100644
--- a/docs/_static/code/getting_started/moviepy_10_minutes/trailer.py
+++ b/docs/_static/code/getting_started/moviepy_10_minutes/trailer.py
@@ -16,13 +16,13 @@ video = VideoFileClip("./resources/bbb.mp4")
# We extract the scenes we want to use
# First the characters
-intro_clip = video.with_subclip(1, 11)
-bird_clip = video.with_subclip(16, 20)
-bunny_clip = video.with_subclip(37, 55)
-rodents_clip = video.with_subclip(
+intro_clip = video.subclipped(1, 11)
+bird_clip = video.subclipped(16, 20)
+bunny_clip = video.subclipped(37, 55)
+rodents_clip = video.subclipped(
"00:03:34.75", "00:03:56"
) # we can also use string notation with format HH:MM:SS.uS
-rambo_clip = video.with_subclip("04:41.5", "04:44.70")
+rambo_clip = video.subclipped("04:41.5", "04:44.70")
#####################
@@ -43,8 +43,8 @@ rambo_clip.preview(fps=20)
##############################
# Well, looking at the rodent scene it is a bit long isn't?
# Let's see how we modify the clip with one of the many clip manipulation method starting by with_*
-# in that case by removing of the clip the part between 00:06:00 to 00:10:00 of the clip, using with_cutout
-rodents_clip = rodents_clip.with_cutout(start_time=4, end_time=10)
+# in that case by removing of the clip the part between 00:06:00 to 00:10:00 of the clip, using with_section_cut_out
+rodents_clip = rodents_clip.with_section_cut_out(start_time=4, end_time=10)
# Note: You may have noticed that we have reassign rodents_clip, this is because all with_* methods return a modified *copy* of the
# original clip instead of modifying it directly. In MoviePy any function starting by with_* is out-place instead of in-place
@@ -210,8 +210,8 @@ rambo_clip = rambo_clip.with_effects(
# Effects are not only for transition, they can also change a clip timing or apparence
# To show that, lets also modify the Rambo-like part of our clip to be in slow motion
-# PS : We do it for effect, but this is one of the few effects that have a direct shortcut, with_multiply_speed
-# the others are with_multiply_volume, resized, croped and rotated
+# PS : We do it for effect, but this is one of the few effects that have a direct shortcut, with_speed_scaled
+# the others are with_volume_scaled, resized, croped and rotated
rambo_clip = rambo_clip.with_effects([vfx.MultiplySpeed(0.5)])
# Because we modified timing of rambo_clip with our MultiplySpeed effect, we must re-assign the following clips timing
diff --git a/docs/_static/code/getting_started/quick_presentation/basic_example.py b/docs/_static/code/getting_started/quick_presentation/basic_example.py
index 2a32d0ec..db231624 100644
--- a/docs/_static/code/getting_started/quick_presentation/basic_example.py
+++ b/docs/_static/code/getting_started/quick_presentation/basic_example.py
@@ -2,10 +2,10 @@
from moviepy import *
# Load file example.mp4 and extract only the subclip from 00:00:10 to 00:00:20
-clip = VideoFileClip("long_examples/example2.mp4").with_subclip(10, 20)
+clip = VideoFileClip("long_examples/example2.mp4").subclipped(10, 20)
# Reduce the audio volume to 80% of his original volume
-clip = clip.with_multiply_volume(0.8)
+clip = clip.with_volume_scaled(0.8)
# Generate a text clip. You can customize the font, color, etc.
txt_clip = TextClip(
diff --git a/docs/_static/code/user_guide/compositing/CompositeAudioClip.py b/docs/_static/code/user_guide/compositing/CompositeAudioClip.py
index a810bfcf..121dc4b2 100644
--- a/docs/_static/code/user_guide/compositing/CompositeAudioClip.py
+++ b/docs/_static/code/user_guide/compositing/CompositeAudioClip.py
@@ -11,7 +11,7 @@ concat = concatenate_audioclips([aclip1, aclip2, aclip3])
# We will play aclip1, then ontop of it aclip2 after 5s, and the aclip3 on top of both after 9s
compo = CompositeAudioClip(
[
- aclip1.with_multiply_volume(1.2),
+ aclip1.with_volume_scaled(1.2),
aclip2.with_start(5), # start at t=5s
aclip3.with_start(9),
]
diff --git a/docs/_static/code/user_guide/compositing/CompositeVideoClip.py b/docs/_static/code/user_guide/compositing/CompositeVideoClip.py
index 1c178550..5da6b518 100644
--- a/docs/_static/code/user_guide/compositing/CompositeVideoClip.py
+++ b/docs/_static/code/user_guide/compositing/CompositeVideoClip.py
@@ -2,7 +2,7 @@ from moviepy import *
# We load all the clips we want to compose
clip1 = VideoFileClip("example.mp4")
-clip2 = VideoFileClip("example2.mp4").with_subclip(0, 1)
+clip2 = VideoFileClip("example2.mp4").subclipped(0, 1)
clip3 = VideoFileClip("example3.mp4")
# We concatenate them and write theme stacked on top of each other, with clip3 over clip2 over clip1
diff --git a/docs/_static/code/user_guide/compositing/concatenate.py b/docs/_static/code/user_guide/compositing/concatenate.py
index edc99137..5bdaf025 100644
--- a/docs/_static/code/user_guide/compositing/concatenate.py
+++ b/docs/_static/code/user_guide/compositing/concatenate.py
@@ -2,7 +2,7 @@ from moviepy import VideoFileClip, concatenate_videoclips
# We load all the clips we want to concatenate
clip1 = VideoFileClip("example.mp4")
-clip2 = VideoFileClip("example2.mp4").with_subclip(0, 1)
+clip2 = VideoFileClip("example2.mp4").subclipped(0, 1)
clip3 = VideoFileClip("example3.mp4")
# We concatenate them and write the result
diff --git a/docs/_static/code/user_guide/compositing/crossfadein.py b/docs/_static/code/user_guide/compositing/crossfadein.py
index ffdae5d2..3127e183 100644
--- a/docs/_static/code/user_guide/compositing/crossfadein.py
+++ b/docs/_static/code/user_guide/compositing/crossfadein.py
@@ -2,7 +2,7 @@ from moviepy import *
# We load all the clips we want to compose
clip1 = VideoFileClip("example.mp4")
-clip2 = VideoFileClip("example2.mp4").with_subclip(0, 1)
+clip2 = VideoFileClip("example2.mp4").subclipped(0, 1)
# Clip2 will be on top of clip1 for 1s
clip1 = clip1.with_end(2)
diff --git a/docs/_static/code/user_guide/compositing/with_position.py b/docs/_static/code/user_guide/compositing/with_position.py
index bd801d3f..b020db85 100644
--- a/docs/_static/code/user_guide/compositing/with_position.py
+++ b/docs/_static/code/user_guide/compositing/with_position.py
@@ -1,7 +1,7 @@
from moviepy import *
# We load all the clips we want to compose
-background = VideoFileClip("example2.mp4").with_subclip(0, 2)
+background = VideoFileClip("example2.mp4").subclipped(0, 2)
title = TextClip(
"./example.ttf",
text="Big Buck Bunny",
@@ -42,7 +42,7 @@ author = author.with_position((left, top))
copyright = copyright.with_position(("center", background.h - copyright.h - 30))
# Finally, we want the logo to be in the center, but to drop as time pass
-# We can do so by setting position as a function that take time as argument, a lot like make_frame
+# We can do so by setting position as a function that take time as argument, a lot like frame_function
top = (background.h - logo.h) / 2
logo = logo.with_position(lambda t: ("center", top + t * 30))
diff --git a/docs/_static/code/user_guide/compositing/with_start.py b/docs/_static/code/user_guide/compositing/with_start.py
index e59848da..ae06bb59 100644
--- a/docs/_static/code/user_guide/compositing/with_start.py
+++ b/docs/_static/code/user_guide/compositing/with_start.py
@@ -2,7 +2,7 @@ from moviepy import *
# We load all the clips we want to compose
clip1 = VideoFileClip("example.mp4")
-clip2 = VideoFileClip("example2.mp4").with_subclip(0, 1)
+clip2 = VideoFileClip("example2.mp4").subclipped(0, 1)
clip3 = VideoFileClip("example3.mp4")
# We want to stop clip1 after 1s
diff --git a/docs/_static/code/user_guide/effects/modify_copy_example.py b/docs/_static/code/user_guide/effects/modify_copy_example.py
index 49595e94..d965b0a0 100644
--- a/docs/_static/code/user_guide/effects/modify_copy_example.py
+++ b/docs/_static/code/user_guide/effects/modify_copy_example.py
@@ -6,14 +6,14 @@ clip = VideoFileClip("example.mp4")
# This does nothing, as multiply_volume will return a copy of clip which you will loose immediatly as you dont store it
# If you was to render clip now, the audio would still be at full volume
-clip.with_multiply_volume(0.1)
+clip.with_volume_scaled(0.1)
# This create a copy of clip in clip_whisper with a volume of only 10% the original, but does not modify the original clip
# If you was to render clip right now, the audio would still be at full volume
# If you was to render clip_whisper, the audio would be a 10% of the original volume
-clip_whisper = clip.with_multiply_volume(0.1)
+clip_whisper = clip.with_volume_scaled(0.1)
# This replace the original clip with a copy of it where volume is only 10% of the original
# If you was to render clip now, the audio would be at 10%
# The original clip is now lost
-clip = clip.with_multiply_volume(0.1)
+clip = clip.with_volume_scaled(0.1)
diff --git a/docs/_static/code/user_guide/loading/AudioArrayClip.py b/docs/_static/code/user_guide/loading/AudioArrayClip.py
index 1ed74ade..6a02d41a 100644
--- a/docs/_static/code/user_guide/loading/AudioArrayClip.py
+++ b/docs/_static/code/user_guide/loading/AudioArrayClip.py
@@ -12,7 +12,7 @@ note_size = int(note_duration * sample_rate)
total_size = note_size * len(notes)
-def make_frame(t, note_frequency):
+def frame_function(t, note_frequency):
return np.sin(note_frequency * 2 * np.pi * t)
@@ -24,7 +24,7 @@ audio_array = np.zeros((total_size, 2))
i = 0
for note, frequency in notes.items():
for _ in range(note_size):
- audio_array[i][0] = make_frame(times[i], frequency)
+ audio_array[i][0] = frame_function(times[i], frequency)
i += 1
# Create an AudioArrayClip from the audio samples
diff --git a/docs/_static/code/user_guide/loading/AudioClip.py b/docs/_static/code/user_guide/loading/AudioClip.py
index 37f51b4c..fe1785c8 100644
--- a/docs/_static/code/user_guide/loading/AudioClip.py
+++ b/docs/_static/code/user_guide/loading/AudioClip.py
@@ -2,7 +2,7 @@ from moviepy import *
import numpy as np
# Producing a sinewave of 440 Hz -> note A
-make_frame_audio = lambda t: np.sin(440 * 2 * np.pi * t)
+frame_function_audio = lambda t: np.sin(440 * 2 * np.pi * t)
# AUDIO CLIPS
-clip = AudioClip(make_frame_audio, duration=3)
+clip = AudioClip(frame_function_audio, duration=3)
diff --git a/docs/_static/code/user_guide/loading/DataVideoClip.py b/docs/_static/code/user_guide/loading/DataVideoClip.py
index d44e04e4..3d59498f 100644
--- a/docs/_static/code/user_guide/loading/DataVideoClip.py
+++ b/docs/_static/code/user_guide/loading/DataVideoClip.py
@@ -13,13 +13,13 @@ dataset = [
# The function make frame take data and create an image of 200x100 px fill with the color
-def make_frame(data):
+def frame_function(data):
frame = np.full((100, 200, 3), data, dtype=np.uint8)
return frame
# We create the DataVideoClip, and we set FPS at 2, making a 3s clip (because len(dataset) = 6, so 6/2=3)
-myclip = DataVideoClip(data=dataset, data_to_frame=make_frame, fps=2)
+myclip = DataVideoClip(data=dataset, data_to_frame=frame_function, fps=2)
# Modifying fps here will change video FPS, not clip FPS
myclip.write_videofile("result.mp4", fps=30)
diff --git a/docs/_static/code/user_guide/loading/VideoClip.py b/docs/_static/code/user_guide/loading/VideoClip.py
index 6d548530..2385eee3 100644
--- a/docs/_static/code/user_guide/loading/VideoClip.py
+++ b/docs/_static/code/user_guide/loading/VideoClip.py
@@ -7,7 +7,7 @@ WIDTH, HEIGHT = (128, 128)
RED = (255, 0, 0)
-def make_frame(t):
+def frame_function(t):
frequency = 1 # One pulse per second
coef = 0.5 * (1 + math.sin(2 * math.pi * frequency * t)) # radius varies over time
radius = WIDTH * coef
@@ -25,7 +25,7 @@ def make_frame(t):
clip = VideoClip(
- make_frame, duration=2
+ frame_function, duration=2
) # we define a 2s duration for the clip to be able to render it later
clip.write_gif(
"circle.gif", fps=15
diff --git a/docs/_static/code/user_guide/loading/VideoFileClip.py b/docs/_static/code/user_guide/loading/VideoFileClip.py
index f798b687..2d24a878 100644
--- a/docs/_static/code/user_guide/loading/VideoFileClip.py
+++ b/docs/_static/code/user_guide/loading/VideoFileClip.py
@@ -6,7 +6,7 @@ myclip = VideoFileClip("example.mp4")
print("Clip duration: {}".format(myclip.duration))
print("Clip fps: {}".format(myclip.fps))
-myclip = myclip.with_subclip(0.5, 2) # Cutting the clip between 0.5 and 2 secs.
+myclip = myclip.subclipped(0.5, 2) # Cutting the clip between 0.5 and 2 secs.
print("Clip duration: {}".format(myclip.duration)) # Cuting will update duration
print("Clip fps: {}".format(myclip.fps)) # and keep fps
diff --git a/docs/_static/code/user_guide/loading/loading.py b/docs/_static/code/user_guide/loading/loading.py
index 4eb9b780..0166cb94 100644
--- a/docs/_static/code/user_guide/loading/loading.py
+++ b/docs/_static/code/user_guide/loading/loading.py
@@ -4,16 +4,16 @@ import numpy as np
# Define some constants for later use
black = (255, 255, 255) # RGB for black
# Random noise image of 200x100
-make_frame = lambda t: np.random.randint(low=0, high=255, size=(100, 200, 3))
+frame_function = lambda t: np.random.randint(low=0, high=255, size=(100, 200, 3))
# A note by producing a sinewave of 440 Hz
-make_frame_audio = lambda t: np.sin(440 * 2 * np.pi * t)
+frame_function_audio = lambda t: np.sin(440 * 2 * np.pi * t)
# Now lets see how to load different type of resources !
# VIDEO CLIPS`
clip = VideoClip(
- make_frame, duration=5
-) # for custom animations, where make_frame is a function returning an image as numpy array for a given time
+ frame_function, duration=5
+) # for custom animations, where frame_function is a function returning an image as numpy array for a given time
clip = VideoFileClip("example.mp4") # for videos
clip = ImageSequenceClip(
"example_img_dir", fps=24
@@ -31,5 +31,5 @@ clip = AudioFileClip(
"example.wav"
) # for audio files, but also videos where you only want the keep the audio track
clip = AudioClip(
- make_frame_audio, duration=3
-) # for custom audio, where make_frame is a function returning a float (or tuple for stereo) for a given time
+ frame_function_audio, duration=3
+) # for custom audio, where frame_function is a function returning a float (or tuple for stereo) for a given time
diff --git a/docs/_static/code/user_guide/loading/masks.py b/docs/_static/code/user_guide/loading/masks.py
index 1ebc002e..233313a2 100644
--- a/docs/_static/code/user_guide/loading/masks.py
+++ b/docs/_static/code/user_guide/loading/masks.py
@@ -2,10 +2,10 @@ from moviepy import *
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
diff --git a/docs/_static/code/user_guide/rendering/preview.py b/docs/_static/code/user_guide/rendering/preview.py
index be7ff92f..a7de2230 100644
--- a/docs/_static/code/user_guide/rendering/preview.py
+++ b/docs/_static/code/user_guide/rendering/preview.py
@@ -1,6 +1,6 @@
from moviepy import *
-myclip = VideoFileClip("./example.mp4").with_subclip(0, 1) # Keep only 0 to 1 sec
+myclip = VideoFileClip("./example.mp4").subclipped(0, 1) # Keep only 0 to 1 sec
# We preview our clip as a video, inheriting FPS and audio of the original clip
myclip.preview()
diff --git a/docs/_static/code/user_guide/rendering/write_gif.py b/docs/_static/code/user_guide/rendering/write_gif.py
index 8f28aa4b..69580f7c 100644
--- a/docs/_static/code/user_guide/rendering/write_gif.py
+++ b/docs/_static/code/user_guide/rendering/write_gif.py
@@ -1,6 +1,6 @@
from moviepy import *
-myclip = VideoFileClip("example.mp4").with_subclip(0, 2)
+myclip = VideoFileClip("example.mp4").subclipped(0, 2)
# Here we just save as GIF
myclip.write_gif("result.gif")
diff --git a/docs/_static/code/user_guide/rendering/write_videofile.py b/docs/_static/code/user_guide/rendering/write_videofile.py
index e42538a6..9abc1cee 100644
--- a/docs/_static/code/user_guide/rendering/write_videofile.py
+++ b/docs/_static/code/user_guide/rendering/write_videofile.py
@@ -1,7 +1,7 @@
from moviepy import *
# We load all the clips we want to compose
-background = VideoFileClip("long_examples/example2.mp4").with_subclip(0, 10)
+background = VideoFileClip("long_examples/example2.mp4").subclipped(0, 10)
title = TextClip(
"./example.ttf",
text="Big Buck Bunny",
diff --git a/docs/getting_started/moviepy_10_minutes.rst b/docs/getting_started/moviepy_10_minutes.rst
index 46298b78..033a37eb 100644
--- a/docs/getting_started/moviepy_10_minutes.rst
+++ b/docs/getting_started/moviepy_10_minutes.rst
@@ -63,7 +63,7 @@ This is a very classic task, so let's turn our main clip into multiple subclips:
:lines: 13-25
-Here, we use the ``with_subclip`` method to extract specific scenes from the main video. We provide the start and end times (in seconds or as text with the format ``HH:MM:SS.µS``) for each scene.
+Here, we use the ``subclipped`` method to extract specific scenes from the main video. We provide the start and end times (in seconds or as text with the format ``HH:MM:SS.µS``) for each scene.
The extracted clips are stored in their respective variables (``intro_clip``, ``bird_clip``, etc.).
Step 3: Take a First Look with Preview
@@ -93,13 +93,13 @@ Step 4: Modify a Clip by Cutting Out a Part of It
--------------------------------------------------
After previewing the clips, we notice that the rodents' scene is a bit long. Let's modify the clip by removing a specific part. It would be nice to remove parts of the scene that we don't need. This is also quite a common task in video-editing.
-To do so, we are going to use the ``with_cutout`` method to remove a portion of the clip between ``00:06:00`` to ``00:10:00``.
+To do so, we are going to use the ``with_section_cut_out`` method to remove a portion of the clip between ``00:06:00`` to ``00:10:00``.
.. literalinclude:: /_static/code/getting_started/moviepy_10_minutes/trailer.py
:language: python
:lines: 41-54
-In that particular case, we have used the ``with_cutout``, but this is only one of the many clip manipulation methods starting with ``with_*``. We will see a few others
+In that particular case, we have used the ``with_section_cut_out``, but this is only one of the many clip manipulation methods starting with ``with_*``. We will see a few others
in this tutorial, but we will miss a lot more. If you want an exhaustive list, go see :ref:`reference_manual`.
.. note::
diff --git a/docs/user_guide/compositing.rst b/docs/user_guide/compositing.rst
index 9f395800..4078ed14 100644
--- a/docs/user_guide/compositing.rst
+++ b/docs/user_guide/compositing.rst
@@ -89,7 +89,7 @@ So, considering that you would want to play ``clip1`` for the first 6 seconds, `
.. note::
When working with timing of your clip, you will frequently want to keep only parts of the original clip.
- To do so, you should take a look at :py:meth:`~moviepy.Clip.Clip.with_subclip` and :py:meth:`~moviepy.Clip.Clip.with_cutout`.
+ To do so, you should take a look at :py:meth:`~moviepy.Clip.Clip.subclipped` and :py:meth:`~moviepy.Clip.Clip.with_section_cut_out`.
Positioning clips
diff --git a/docs/user_guide/loading.rst b/docs/user_guide/loading.rst
index 2a77b6bb..28bdb87d 100644
--- a/docs/user_guide/loading.rst
+++ b/docs/user_guide/loading.rst
@@ -65,7 +65,7 @@ VideoClip
""""""""""
:py:class:`~moviepy.video.VideoClip.VideoClip` is the base class for all the other video clips in MoviePy. If all you want is to edit video files, you will never need it. This class is practical when you want to make animations from frames that are generated by another library.
-All you need is to define a function ``make_frame(t)`` which returns a `HxWx3` numpy array (of 8-bits integers) representing the frame at time ``t``.
+All you need is to define a function ``frame_function(t)`` which returns a `HxWx3` numpy array (of 8-bits integers) representing the frame at time ``t``.
Here is an example where we will create a pulsating red circle with graphical library `pillow <https://pypi.org/project/Pillow/>`_.
@@ -81,7 +81,7 @@ Resulting in this.
.. note::
- Clips that are made with a ``make_frame`` do not have an explicit frame rate nor duration by default, so you must provide duration at clip creation and a frame rate (``fps``, frames per second) for :py:meth:`~moviepy.video.VideoClip.VideoClip.write_gif` and :py:meth:`~moviepy.video.VideoClip.VideoClip.write_videofile`, and more generally for any methods that requires iterating through the frames.
+ Clips that are made with a ``frame_function`` do not have an explicit frame rate nor duration by default, so you must provide duration at clip creation and a frame rate (``fps``, frames per second) for :py:meth:`~moviepy.video.VideoClip.VideoClip.write_gif` and :py:meth:`~moviepy.video.VideoClip.VideoClip.write_videofile`, and more generally for any methods that requires iterating through the frames.
For more, see :py:class:`~moviepy.video.VideoClip.VideoClip`.
@@ -137,7 +137,7 @@ UpdatedVideoClip
.. warning::
This is really advanced usage, you will probably never need it, if you do, please go read the code.
-:py:class:`~moviepy.video.io.VideoClip.UpdatedVideoClip` is a video whose make_frame requires some objects to be updated before we can compute it.
+:py:class:`~moviepy.video.io.VideoClip.UpdatedVideoClip` is a video whose frame_function requires some objects to be updated before we can compute it.
This is particularly practical in science where some algorithm needs to make some steps before a new frame can be generated, or maybe when trying to make a video based on a live exterior context.
@@ -244,7 +244,7 @@ AudioClip
:py:class:`~moviepy.audio.AudioClip.AudioClip` is the base class for all audio clips. If all you want is to edit audio files, you will never need it.
-All you need is to define a function ``make_frame(t)`` which returns a ``Nx1`` or ``Nx2`` numpy array representing the sound at time ``t``.
+All you need is to define a function ``frame_function(t)`` which returns a ``Nx1`` or ``Nx2`` numpy array representing the sound at time ``t``.
.. literalinclude:: /_static/code/user_guide/loading/AudioClip.py
:language: python
diff --git a/docs/user_guide/modifying.rst b/docs/user_guide/modifying.rst
index be98470d..23b857b1 100644
--- a/docs/user_guide/modifying.rst
+++ b/docs/user_guide/modifying.rst
@@ -37,7 +37,7 @@ It means that creating a new clip is neither time nor memory hungry, all the com
Time representations in MoviePy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Many methods that we will see accept duration or timepoint as arguments. For instance :py:meth:`clip.with_subclip(t_start, t_end) <moviepy.Clip.Clip.with_subclip(t_start, t_end)>` which cuts the clip between two timepoints.
+Many methods that we will see accept duration or timepoint as arguments. For instance :py:meth:`clip.subclipped(t_start, t_end) <moviepy.Clip.Clip.subclipped(t_start, t_end)>` which cuts the clip between two timepoints.
MoviePy usually accept duration and timepoint as either :
@@ -45,7 +45,7 @@ MoviePy usually accept duration and timepoint as either :
* a ``tuple`` with ``(minutes, seconds)`` or ``(hours, minutes, seconds)``.
* a ``string`` such as ``'00:03:50.54'``.
-Also, you can usually provide negative times, indicating a time from the end of the clip. For example, ``clip.with_subclip(-20, -10)`` cuts the clip between 20s before the end and 10s before the end.
+Also, you can usually provide negative times, indicating a time from the end of the clip. For example, ``clip.subclipped(-20, -10)`` cuts the clip between 20s before the end and 10s before the end.
Modify a clip using the ``with_*`` methods
diff --git a/docs/user_guide/rendering.rst b/docs/user_guide/rendering.rst
index 535fd444..52474c53 100644
--- a/docs/user_guide/rendering.rst
+++ b/docs/user_guide/rendering.rst
@@ -24,7 +24,7 @@ The first thing you can do is to preview your clip as a video, by calling method
.. literalinclude:: /_static/code/user_guide/rendering/preview.py
:language: python
-You will probably frequently want to preview only a small portion of your clip, though ``preview`` do not offer such capabilities, you can easily emulate such behavior by using :py:meth:`~moviepy.Clip.Clip.with_subclip`.
+You will probably frequently want to preview only a small portion of your clip, though ``preview`` do not offer such capabilities, you can easily emulate such behavior by using :py:meth:`~moviepy.Clip.Clip.subclipped`.
.. note::
It is quite frequent for a clip preview to be out of sync, or to play slower than it should. It means that your computer is not powerful enough to render the clip in real time.
diff --git a/moviepy/Clip.py b/moviepy/Clip.py
index af0937b7..4bdd9583 100644
--- a/moviepy/Clip.py
+++ b/moviepy/Clip.py
@@ -79,12 +79,12 @@ class Clip:
if t == self.memoized_t:
return self.memoized_frame
else:
- frame = self.make_frame(t)
+ frame = self.frame_function(t)
self.memoized_t = t
self.memoized_frame = frame
return frame
else:
- return self.make_frame(t)
+ return self.frame_function(t)
def transform(self, func, apply_to=None, keep_duration=True):
"""General processing of a clip.
@@ -126,8 +126,8 @@ class Clip:
if apply_to is None:
apply_to = []
- # mf = copy(self.make_frame)
- new_clip = self.with_make_frame(lambda t: func(self.get_frame, t))
+ # mf = copy(self.frame_function)
+ new_clip = self.with_updated_frame_function(lambda t: func(self.get_frame, t))
if not keep_duration:
new_clip.duration = None
@@ -294,17 +294,17 @@ class Clip:
self.start = self.end - duration
@outplace
- def with_make_frame(self, make_frame):
- """Sets a ``make_frame`` attribute for the clip. Useful for setting
+ def with_updated_frame_function(self, frame_function):
+ """Sets a ``frame_function`` attribute for the clip. Useful for setting
arbitrary/complicated videoclips.
Parameters
----------
- make_frame : function
+ frame_function : function
New frame creator function for the clip.
"""
- self.make_frame = make_frame
+ self.frame_function = frame_function
def with_fps(self, fps, change_duration=False):
"""Returns a copy of the clip with a new default fps for functions like
@@ -358,7 +358,7 @@ class Clip:
@convert_parameter_to_seconds(["start_time", "end_time"])
@apply_to_mask
@apply_to_audio
- def with_subclip(self, start_time=0, end_time=None):
+ def subclipped(self, start_time=0, end_time=None):
"""Returns a clip playing the content of the current clip between times
``start_time`` and ``end_time``, which can be expressed in seconds
(15.35), in (min, sec), in (hour, min, sec), or as a string:
@@ -384,7 +384,7 @@ class Clip:
For instance:
>>> # cut the last two seconds of the clip:
- >>> new_clip = clip.with_subclip(0, -2)
+ >>> new_clip = clip.subclipped(0, -2)
If ``end_time`` is provided or if the clip has a duration attribute,
the duration of the returned clip is set automatically.
@@ -426,7 +426,7 @@ class Clip:
return new_clip
@convert_parameter_to_seconds(["start_time", "end_time"])
- def with_cutout(self, start_time, end_time):
+ def with_section_cut_out(self, start_time, end_time):
"""
Returns a clip playing the content of the current clip but
skips the extract between ``start_time`` and ``end_time``, which can be
@@ -459,7 +459,7 @@ class Clip:
else: # pragma: no cover
return new_clip
- def with_multiply_speed(self, factor: float = None, final_duration: float = None):
+ def with_speed_scaled(self, factor: float = None, final_duration: float = None):
"""Returns a clip playing the current clip but at a speed multiplied
by ``factor``. For info on the parameters, please see ``vfx.MultiplySpeed``.
"""
@@ -469,7 +469,7 @@ class Clip:
[MultiplySpeed(factor=factor, final_duration=final_duration)]
)
- def with_multiply_volume(self, factor: float, start_time=None, end_time=None):
+ def with_volume_scaled(self, factor: float, start_time=None, end_time=None):
"""Returns a new clip with audio volume multiplied by the value `factor`.
For info on the parameters, please see ``afx.MultiplyVolume``
"""
@@ -608,7 +608,7 @@ class Clip:
Simple slicing is implemented via `subclip`.
So, ``clip[t_start:t_end]`` is equivalent to
- ``clip.with_subclip(t_start, t_end)``. If ``t_start`` is not
+ ``clip.subclipped(t_start, t_end)``. If ``t_start`` is not
given, default to ``0``, if ``t_end`` is not given,
default to ``self.duration``.
@@ -633,7 +633,7 @@ class Clip:
if isinstance(key, slice):
# support for [start:end:speed] slicing. If speed is negative
# a time mirror is applied.
- clip = self.with_subclip(key.start or 0, key.stop or self.duration)
+ clip = self.subclipped(key.start or 0, key.stop or self.duration)
if key.step:
# change speed of the subclip
diff --git a/moviepy/audio/AudioClip.py b/moviepy/audio/AudioClip.py
index 43e61c3c..6c8ef7b9 100644
--- a/moviepy/audio/AudioClip.py
+++ b/moviepy/audio/AudioClip.py
@@ -22,7 +22,7 @@ class AudioClip(Clip):
See ``AudioFileClip`` and ``CompositeAudioClip`` for usable classes.
- An AudioClip is a Clip with a ``make_frame`` attribute of
+ An AudioClip is a Clip with a ``frame_function`` attribute of
the form `` t -> [ f_t ]`` for mono sound and
``t-> [ f1_t, f2_t ]`` for stereo sound (the arrays are Numpy arrays).
The `f_t` are floats between -1 and 1. These bounds can be
@@ -32,7 +32,7 @@ class AudioClip(Clip):
Parameters
----------
- make_frame
+ frame_function
A function `t-> frame at time t`. The frame does not mean much
for a sound, it is just a float. What 'makes' the sound are
the variations of that float in the time.
@@ -49,28 +49,28 @@ class AudioClip(Clip):
>>> # Plays the note A in mono (a sine wave of frequency 440 Hz)
>>> import numpy as np
- >>> make_frame = lambda t: np.sin(440 * 2 * np.pi * t)
- >>> clip = AudioClip(make_frame, duration=5, fps=44100)
+ >>> frame_function = lambda t: np.sin(440 * 2 * np.pi * t)
+ >>> clip = AudioClip(frame_function, duration=5, fps=44100)
>>> clip.preview()
>>> # Plays the note A in stereo (two sine waves of frequencies 440 and 880 Hz)
- >>> make_frame = lambda t: np.array([
+ >>> frame_function = lambda t: np.array([
... np.sin(440 * 2 * np.pi * t),
... np.sin(880 * 2 * np.pi * t)
... ]).T.copy(order="C")
- >>> clip = AudioClip(make_frame, duration=3, fps=44100)
+ >>> clip = AudioClip(frame_function, duration=3, fps=44100)
>>> clip.preview()
"""
- def __init__(self, make_frame=None, duration=None, fps=None):
+ def __init__(self, frame_function=None, duration=None, fps=None):
super().__init__()
if fps is not None:
self.fps = fps
- if make_frame is not None:
- self.make_frame = make_frame
+ if frame_function is not None:
+ self.frame_function = frame_function
frame0 = self.get_frame(0)
if hasattr(frame0, "__iter__"):
self.nchannels = len(list(frame0))
@@ -335,7 +335,7 @@ class AudioArrayClip(AudioClip):
self.fps = fps
self.duration = 1.0 * len(array) / fps
- def make_frame(t):
+ def frame_function(t):
"""Complicated, but must be able to handle the case where t
is a list of the form sin(t).
"""
@@ -352,7 +352,7 @@ class AudioArrayClip(AudioClip):
else:
return self.array[i]
- self.make_frame = make_frame
+ self.frame_function = frame_function
self.nchannels = len(list(self.get_frame(0)))
@@ -400,7 +400,7 @@ class CompositeAudioClip(AudioClip):
"""Returns ending times for all clips in the composition."""
return (clip.end for clip in self.clips)
- def make_frame(self, t):
+ def frame_function(self, t):
"""Renders a frame for the composition for the time ``t``."""
played_parts = [clip.is_playing(t) for clip in self.clips]
diff --git a/moviepy/audio/fx/AudioDelay.py b/moviepy/audio/fx/AudioDelay.py
index 25c98317..2deca226 100644
--- a/moviepy/audio/fx/AudioDelay.py
+++ b/moviepy/audio/fx/AudioDelay.py
@@ -40,10 +40,10 @@ class AudioDelay(Effect):
... ])
>>> # stereo A note
- >>> make_frame = lambda t: np.array(
+ >>> frame_function = 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 = AudioClip(frame_function=frame_function, duration=0.1, fps=44100)
... clip = clip.with_effects([afx.AudioDelay(offset=.2, n_repeats=11, decay=0)])
"""
diff --git a/moviepy/audio/io/AudioFileClip.py b/moviepy/audio/io/AudioFileClip.py
index dd241f84..f23bd570 100644
--- a/moviepy/audio/io/AudioFileClip.py
+++ b/moviepy/audio/io/AudioFileClip.py
@@ -73,7 +73,7 @@ class AudioFileClip(AudioClip):
self.buffersize = self.reader.buffersize
self.filename = filename
- self.make_frame = lambda t: self.reader.get_frame(t)
+ self.frame_function = lambda t: self.reader.get_frame(t)
self.nchannels = self.reader.nchannels
def close(self):
diff --git a/moviepy/decorators.py b/moviepy/decorators.py
index ff0a17e0..9c7b9a21 100644
--- a/moviepy/decorators.py
+++ b/moviepy/decorators.py
@@ -110,7 +110,7 @@ def convert_path_to_string(varnames):
def add_mask_if_none(func, clip, *args, **kwargs):
"""Add a mask to the clip if there is none."""
if clip.mask is None:
- clip = clip.with_add_mask()
+ clip = clip.with_mask()
return func(clip, *args, **kwargs)
diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py
index 9c775555..4bc3ed47 100644
--- a/moviepy/video/VideoClip.py
+++ b/moviepy/video/VideoClip.py
@@ -8,7 +8,7 @@ import copy as _copy
import os
import threading
from numbers import Real
-from typing import TYPE_CHECKING, List
+from typing import TYPE_CHECKING, Callable, List, Union
import numpy as np
import proglog
@@ -77,7 +77,7 @@ class VideoClip(Clip):
is_mask
Boolean set to `True` if the clip is a mask.
- make_frame
+ frame_function
A function ``t-> frame at time t`` where ``frame`` is a
w*h*3 RGB array.
@@ -104,16 +104,16 @@ class VideoClip(Clip):
"""
def __init__(
- self, make_frame=None, is_mask=False, duration=None, has_constant_size=True
+ self, frame_function=None, is_mask=False, duration=None, has_constant_size=True
):
super().__init__()
self.mask = None
self.audio = None
self.pos = lambda t: (0, 0)
self.relative_pos = False
- self.layer = 0
- if make_frame:
- self.make_frame = make_frame
+ self.layer_index = 0
+ if frame_function:
+ self.frame_function = frame_function
self.size = self.get_frame(0).shape[:2][::-1]
self.is_mask = is_mask
self.has_constant_size = has_constant_size
@@ -151,7 +151,7 @@ class VideoClip(Clip):
This method is intensively used to produce new clips every time
there is an outplace transformation of the clip (clip.resize,
- clip.with_subclip, etc.)
+ clip.subclipped, etc.)
Acts like a deepcopy except for the fact that readers and other
possible unpickleables objects are not copied.
@@ -327,7 +327,7 @@ class VideoClip(Clip):
--------
>>> from moviepy import VideoFileClip
- >>> clip = VideoFileClip("myvideo.mp4").with_subclip(100,120)
+ >>> clip = VideoFileClip("myvideo.mp4").subclipped(100,120)
>>> clip.write_videofile("my_new_video.mp4")
>>> clip.close()
@@ -629,7 +629,7 @@ class VideoClip(Clip):
# -----------------------------------------------------------------
# F I L T E R I N G
- def with_sub_effects(
+ def with_effects_on_subclip(
self, effects: List["Effect"], start_time=0, end_time=None, **kwargs
):
"""Apply a transformation to a part of the clip.
@@ -646,9 +646,9 @@ class VideoClip(Clip):
>>> 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).with_effects(effects, **kwargs)
- right = None if (end_time is None) else self.with_subclip(start_time=end_time)
+ left = None if (start_time == 0) else self.subclipped(0, start_time)
+ center = self.subclipped(start_time, end_time).with_effects(effects, **kwargs)
+ right = None if (end_time is None) else self.subclipped(start_time=end_time)
clips = [clip for clip in [left, center, right] if clip is not None]
@@ -771,28 +771,7 @@ class VideoClip(Clip):
pos = map(int, pos)
return blit(im_img, picture, pos, mask=im_mask)
- def with_add_mask(self):
- """Add a mask VideoClip to the VideoClip.
-
- Returns a copy of the clip with a completely opaque mask
- (made of ones). This makes computations slower compared to
- having a None mask but can be useful in many cases. Choose
-
- Set ``constant_size`` to `False` for clips with moving
- image size.
- """
- 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 make_frame(t):
- return np.ones(self.get_frame(t).shape[:2], dtype=float)
-
- mask = VideoClip(is_mask=True, make_frame=make_frame)
- return self.with_mask(mask.with_duration(self.duration))
-
- def with_on_color(self, size=None, color=(0, 0, 0), pos=None, col_opacity=None):
+ def with_background_color(self, size=None, color=(0, 0, 0), pos=None, opacity=None):
"""Place the clip on a colored background.
Returns a clip made of the current clip overlaid on a color
@@ -812,7 +791,7 @@ class VideoClip(Clip):
pos
Position of the clip in the final clip. 'center' is the default
- col_opacity
+ opacity
Parameter in 0..1 indicating the opacity of the colored
background.
"""
@@ -823,10 +802,10 @@ class VideoClip(Clip):
if pos is None:
pos = "center"
- if col_opacity is not None:
+ if opacity is not None:
colorclip = ColorClip(
size, color=color, duration=self.duration
- ).with_opacity(col_opacity)
+ ).with_opacity(opacity)
result = CompositeVideoClip([colorclip, self.with_position(pos)])
else:
result = CompositeVideoClip(
@@ -846,13 +825,15 @@ class VideoClip(Clip):
return result
@outplace
- def with_make_frame(self, mf):
+ def with_updated_frame_function(
+ self, frame_function: Callable[[float], np.ndarray]
+ ):
"""Change the clip's ``get_frame``.
- Returns a copy of the VideoClip instance, with the make_frame
+ Returns a copy of the VideoClip instance, with the frame_function
attribute set to `mf`.
"""
- self.make_frame = mf
+ self.frame_function = frame_function
self.size = self.get_frame(0).shape[:2][::-1]
@outplace
@@ -865,15 +846,28 @@ class VideoClip(Clip):
self.audio = audioclip
@outplace
- def with_mask(self, mask):
+ def with_mask(self, mask: Union["VideoClip", str] = "auto"):
"""Set the clip's mask.
Returns a copy of the VideoClip with the mask attribute set to
``mask``, which must be a greyscale (values in 0-1) VideoClip.
"""
- assert mask is None or mask.is_mask
+ if mask == "auto":
+ if self.has_constant_size:
+ mask = ColorClip(self.size, 1.0, is_mask=True)
+ 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)
self.mask = mask
+ @outplace
+ def without_mask(self):
+ """Remove the clip's mask."""
+ self.mask = None
+
@add_mask_if_none
@outplace
def with_opacity(self, opacity):
@@ -918,13 +912,13 @@ class VideoClip(Clip):
@apply_to_mask
@outplace
- def with_layer(self, layer):
+ def with_layer_index(self, index):
"""Set the clip's layer in compositions. Clips with a greater ``layer``
attribute will be displayed on top of others.
Note: Only has effect when the clip is used in a CompositeVideoClip.
"""
- self.layer = layer
+ self.layer_index = index
def resized(self, new_size=None, height=None, width=None, apply_to_mask=True):
"""Returns a video clip that is a resized version of the clip.
@@ -1122,12 +1116,12 @@ class DataVideoClip(VideoClip):
self.data_to_frame = data_to_frame
self.fps = fps
- def make_frame(t):
+ def frame_function(t):
return self.data_to_frame(self.data[int(self.fps * t)])
VideoClip.__init__(
self,
- make_frame,
+ frame_function,
is_mask=is_mask,
duration=1.0 * len(data) / fps,
has_constant_size=has_constant_size,
@@ -1136,14 +1130,14 @@ class DataVideoClip(VideoClip):
class UpdatedVideoClip(VideoClip):
"""
- Class of clips whose make_frame requires some objects to
+ Class of clips whose frame_function requires some objects to
be updated. Particularly practical in science where some
algorithm needs to make some steps before a new frame can
be generated.
- UpdatedVideoClips have the following make_frame:
+ UpdatedVideoClips have the following frame_function:
- >>> def make_frame(t):
+ >>> def frame_function(t):
>>> while self.world.clip_t < t:
>>> world.update() # updates, and increases world.clip_t
>>> return world.to_frame()
@@ -1169,13 +1163,13 @@ class UpdatedVideoClip(VideoClip):
def __init__(self, world, is_mask=False, duration=None):
self.world = world
- def make_frame(t):
+ def frame_function(t):
while self.world.clip_t < t:
world.update()
return world.to_frame()
VideoClip.__init__(
- self, make_frame=make_frame, is_mask=is_mask, duration=duration
+ self, frame_function=frame_function, is_mask=is_mask, duration=duration
)
@@ -1246,7 +1240,7 @@ class ImageClip(VideoClip):
# if the image was just a 2D mask, it should arrive here
# unchanged
- self.make_frame = lambda t: img
+ self.frame_function = lambda t: img
self.size = img.shape[:2][::-1]
self.img = img
@@ -1278,7 +1272,7 @@ class ImageClip(VideoClip):
apply_to = []
arr = image_func(self.get_frame(0))
self.size = arr.shape[:2][::-1]
- self.make_frame = lambda t: arr
+ self.frame_function = lambda t: arr
self.img = arr
for attr in apply_to:
@@ -1873,7 +1867,7 @@ class BitmapClip(VideoClip):
VideoClip.__init__(
self,
- make_frame=lambda t: frame_array[int(t * fps)],
+ frame_function=lambda t: frame_array[int(t * fps)],
is_mask=is_mask,
duration=duration,
)
diff --git a/moviepy/video/compositing/CompositeVideoClip.py b/moviepy/video/compositing/CompositeVideoClip.py
index 99752d31..df905c29 100644
--- a/moviepy/video/compositing/CompositeVideoClip.py
+++ b/moviepy/video/compositing/CompositeVideoClip.py
@@ -87,7 +87,7 @@ class CompositeVideoClip(VideoClip):
self.created_bg = True
# order self.clips by layer
- self.clips = sorted(self.clips, key=lambda clip: clip.layer)
+ self.clips = sorted(self.clips, key=lambda clip: clip.layer_index)
# compute duration
ends = [clip.end for clip in self.clips]
@@ -104,11 +104,11 @@ class CompositeVideoClip(VideoClip):
# compute mask if necessary
if transparent:
maskclips = [
- (clip.mask if (clip.mask is not None) else clip.with_add_mask().mask)
+ (clip.mask if (clip.mask is not None) else clip.with_mask().mask)
.with_position(clip.pos)
.with_end(clip.end)
.with_start(clip.start, change_end=False)
- .with_layer(clip.layer)
+ .with_layer_index(clip.layer_index)
for clip in self.clips
]
@@ -116,7 +116,7 @@ class CompositeVideoClip(VideoClip):
maskclips, self.size, is_mask=True, bg_color=0.0
)
- def make_frame(self, t):
+ def frame_function(self, t):
"""The clips playing at time `t` are blitted over one another."""
frame = self.bg.get_frame(t).astype("uint8")
im = Image.fromarray(frame)
@@ -284,7 +284,7 @@ def concatenate_videoclips(
if method == "chain":
- def make_frame(t):
+ def frame_function(t):
i = max([i for i, e in enumerate(timings) if e <= t])
return clips[i].get_frame(t - timings[i])
@@ -294,7 +294,7 @@ def concatenate_videoclips(
mask.duration = clip.duration
return mask
- result = VideoClip(is_mask=is_mask, make_frame=make_frame)
+ result = VideoClip(is_mask=is_mask, frame_function=frame_function)
if any([clip.mask is not None for clip in clips]):
masks = [get_mask(clip) for clip in clips]
result.mask = concatenate_videoclips(masks, method="chain", is_mask=True)
diff --git a/moviepy/video/fx/Blink.py b/moviepy/video/fx/Blink.py
index 2274c02d..dd37f7f6 100644
--- a/moviepy/video/fx/Blink.py
+++ b/moviepy/video/fx/Blink.py
@@ -17,7 +17,7 @@ class Blink(Effect):
def apply(self, clip):
"""Apply the effect to the clip."""
if clip.mask is None:
- clip = clip.with_add_mask()
+ clip = clip.with_mask()
duration = self.duration_on + self.duration_off
clip.mask = clip.mask.transform(
diff --git a/moviepy/video/fx/CrossFadeIn.py b/moviepy/video/fx/CrossFadeIn.py
index 09d179c6..759646ec 100644
--- a/moviepy/video/fx/CrossFadeIn.py
+++ b/moviepy/video/fx/CrossFadeIn.py
@@ -19,7 +19,7 @@ class CrossFadeIn(Effect):
raise ValueError("Attribute 'duration' not set")
if clip.mask is None:
- clip = clip.with_add_mask()
+ clip = clip.with_mask()
clip.mask.duration = clip.duration
clip.mask = clip.mask.with_effects([FadeIn(self.duration)])
diff --git a/moviepy/video/fx/CrossFadeOut.py b/moviepy/video/fx/CrossFadeOut.py
index 5076240a..d86671db 100644
--- a/moviepy/video/fx/CrossFadeOut.py
+++ b/moviepy/video/fx/CrossFadeOut.py
@@ -19,7 +19,7 @@ class CrossFadeOut(Effect):
raise ValueError("Attribute 'duration' not set")
if clip.mask is None:
- clip = clip.with_add_mask()
+ clip = clip.with_mask()
clip.mask.duration = clip.duration
clip.mask = clip.mask.with_effects([FadeOut(self.duration)])
diff --git a/moviepy/video/fx/MakeLoopable.py b/moviepy/video/fx/MakeLoopable.py
index 5632b7c1..3680bf25 100644
--- a/moviepy/video/fx/MakeLoopable.py
+++ b/moviepy/video/fx/MakeLoopable.py
@@ -25,6 +25,6 @@ class MakeLoopable(Effect):
clip2 = clip.with_effects([CrossFadeIn(self.overlap_duration)]).with_start(
clip.duration - self.overlap_duration
)
- return CompositeVideoClip([clip, clip2]).with_subclip(
+ return CompositeVideoClip([clip, clip2]).subclipped(
self.overlap_duration, clip.duration
)
diff --git a/moviepy/video/fx/Margin.py b/moviepy/video/fx/Margin.py
index 77c5389c..f696faa4 100644
--- a/moviepy/video/fx/Margin.py
+++ b/moviepy/video/fx/Margin.py
@@ -48,7 +48,7 @@ class Margin(Effect):
def add_margin(self, clip: Clip):
"""Add margins to the clip."""
if (self.opacity != 1.0) and (clip.mask is None) and not (clip.is_mask):
- clip = clip.with_add_mask()
+ clip = clip.with_mask()
if self.margin_size is not None:
self.left = self.right = self.top = self.bottom = self.margin_size
diff --git a/moviepy/video/fx/Rotate.py b/moviepy/video/fx/Rotate.py
index b19c5e4e..4fb9a593 100644
--- a/moviepy/video/fx/Rotate.py
+++ b/moviepy/video/fx/Rotate.py
@@ -16,7 +16,7 @@ class Rotate(Effect):
and ``bg_color`` are not ``None``, there will be black borders.
You can make them transparent with:
- >>> new_clip = clip.with_add_mask().rotate(72)
+ >>> new_clip = clip.with_mask().rotate(72)
Parameters
----------
diff --git a/moviepy/video/io/ImageSequenceClip.py b/moviepy/video/io/ImageSequenceClip.py
index 01ff5535..96b407f0 100644
--- a/moviepy/video/io/ImageSequenceClip.py
+++ b/moviepy/video/io/ImageSequenceClip.py
@@ -121,7 +121,7 @@ class ImageSequenceClip(VideoClip):
self.last_index = None
self.last_image = None
- def make_frame(t):
+ def frame_function(t):
index = find_image_index(t)
if index != self.last_index:
@@ -135,7 +135,7 @@ class ImageSequenceClip(VideoClip):
self.mask.last_index = None
self.mask.last_image = None
- def mask_make_frame(t):
+ def mask_frame_function(t):
index = find_image_index(t)
if index != self.mask.last_index:
frame = imread(self.sequence[index])[:, :, 3]
@@ -144,24 +144,24 @@ class ImageSequenceClip(VideoClip):
return self.mask.last_image
- self.mask.make_frame = mask_make_frame
- self.mask.size = mask_make_frame(0).shape[:2][::-1]
+ self.mask.frame_function = mask_frame_function
+ self.mask.size = mask_frame_function(0).shape[:2][::-1]
else:
- def make_frame(t):
+ def frame_function(t):
index = find_image_index(t)
return self.sequence[index][:, :, :3]
if with_mask and (self.sequence[0].shape[2] == 4):
self.mask = VideoClip(is_mask=True)
- def mask_make_frame(t):
+ def mask_frame_function(t):
index = find_image_index(t)
return 1.0 * self.sequence[index][:, :, 3] / 255
- self.mask.make_frame = mask_make_frame
- self.mask.size = mask_make_frame(0).shape[:2][::-1]
+ self.mask.frame_function = mask_frame_function
+ self.mask.size = mask_frame_function(0).shape[:2][::-1]
- self.make_frame = make_frame
- self.size = make_frame(0).shape[:2][::-1]
+ self.frame_function = frame_function
+ self.size = frame_function(0).shape[:2][::-1]
diff --git a/moviepy/video/io/VideoFileClip.py b/moviepy/video/io/VideoFileClip.py
index 1f41f4ee..e8486b38 100644
--- a/moviepy/video/io/VideoFileClip.py
+++ b/moviepy/video/io/VideoFileClip.py
@@ -125,18 +125,18 @@ class VideoFileClip(VideoClip):
self.filename = filename
if has_mask:
- self.make_frame = lambda t: self.reader.get_frame(t)[:, :, :3]
+ self.frame_function = lambda t: self.reader.get_frame(t)[:, :, :3]
- def mask_make_frame(t):
+ def mask_frame_function(t):
return self.reader.get_frame(t)[:, :, 3] / 255.0
self.mask = VideoClip(
- is_mask=True, make_frame=mask_make_frame
+ is_mask=True, frame_function=mask_frame_function
).with_duration(self.duration)
self.mask.fps = self.fps
else:
- self.make_frame = lambda t: self.reader.get_frame(t)
+ self.frame_function = lambda t: self.reader.get_frame(t)
# Make a reader for the audio, if any.
if audio and self.reader.infos["audio_found"]:
diff --git a/moviepy/video/tools/cuts.py b/moviepy/video/tools/cuts.py
index 2baaa6da..6c7f30bb 100644
--- a/moviepy/video/tools/cuts.py
+++ b/moviepy/video/tools/cuts.py
@@ -31,7 +31,7 @@ def find_video_period(clip, fps=None, start_time=0.3):
>>> from moviepy import *
>>> from moviepy.video.tools.cuts import find_video_period
>>>
- >>> clip = VideoFileClip("media/chaplin.mp4").with_subclip(0, 1).loop(2)
+ >>> clip = VideoFileClip("media/chaplin.mp4").subclipped(0, 1).loop(2)
>>> round(videotools.find_video_period(clip, fps=80), 6)
1
"""
@@ -237,7 +237,7 @@ class FramesMatches(list):
... clip, distance_threshold=10, max_duration=3, # will take time
... )
>>> best = matches.filter(lambda m: m.time_span > 1.5).best()
- >>> clip.with_subclip(best.start_time, best.end_time).write_gif("foo.gif")
+ >>> clip.subclipped(best.start_time, best.end_time).write_gif("foo.gif")
"""
N_pixels = clip.w * clip.h * 3
@@ -342,7 +342,7 @@ class FramesMatches(list):
>>> from moviepy import *
>>> from moviepy.video.tools.cuts import FramesMatches
>>>
- >>> ch_clip = VideoFileClip("media/chaplin.mp4").with_subclip(1, 4)
+ >>> ch_clip = VideoFileClip("media/chaplin.mp4").subclipped(1, 4)
>>> mirror_and_clip = [ch_clip.with_effects([vfx.TimeMirror()]), ch_clip]
>>> clip = concatenate_videoclips(mirror_and_clip)
>>>
@@ -430,7 +430,7 @@ class FramesMatches(list):
>>> from moviepy import *
>>> from moviepy.video.tools.cuts import FramesMatches
>>>
- >>> ch_clip = VideoFileClip("media/chaplin.mp4").with_subclip(1, 4)
+ >>> ch_clip = VideoFileClip("media/chaplin.mp4").subclipped(1, 4)
>>> clip = concatenate_videoclips([ch_clip.time_mirror(), ch_clip])
>>>
>>> result = FramesMatches.from_clip(clip, 10, 3).select_scenes(
@@ -446,7 +446,7 @@ class FramesMatches(list):
"""
for start, end, _, _ in self:
name = "%s/%08d_%08d.gif" % (gifs_dir, 100 * start, 100 * end)
- clip.with_subclip(start, end).write_gif(name, **kwargs)
+ clip.subclipped(start, end).write_gif(name, **kwargs)
@use_clip_fps_by_default
diff --git a/moviepy/video/tools/subtitles.py b/moviepy/video/tools/subtitles.py
index fa1309dd..856ddb12 100644
--- a/moviepy/video/tools/subtitles.py
+++ b/moviepy/video/tools/subtitles.py
@@ -109,7 +109,7 @@ class SubtitlesClip(VideoClip):
return sub
- def make_frame(t):
+ def frame_function(t):
sub = add_textclip_if_none(t)
return self.textclips[sub].get_frame(t) if sub else np.array([[[0, 0, 0]]])
@@ -117,7 +117,7 @@ class SubtitlesClip(VideoClip):
sub = add_textclip_if_none(t)
return self.textclips[sub].mask.get_frame(t) if sub else np.array([[0]])
- self.make_frame = make_frame
+ self.frame_function = frame_function
hasmask = bool(self.make_textclip("T").mask)
self.mask = VideoClip(make_mask_frame, is_mask=True) if hasmask else None
diff --git a/tests/conftest.py b/tests/conftest.py
index f1752d1f..e673a8f4 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -30,7 +30,7 @@ DOC_EXAMPLES_MEDIAS_DIR = "media/doc_medias"
@functools.lru_cache(maxsize=None)
def get_video(start_time=0, end_time=1):
- return VideoFileClip("media/big_buck_bunny_432_433.webm").with_subclip(
+ return VideoFileClip("media/big_buck_bunny_432_433.webm").subclipped(
start_time, end_time
)
diff --git a/tests/test_AudioClips.py b/tests/test_AudioClips.py
index ca62c1b4..b818d4b9 100644
--- a/tests/test_AudioClips.py
+++ b/tests/test_AudioClips.py
@@ -162,7 +162,7 @@ def test_concatenate_audioclip_with_audiofileclip(util, stereo_wave):
def test_concatenate_audiofileclips(util):
- clip1 = AudioFileClip("media/crunching.mp3").with_subclip(1, 4)
+ clip1 = AudioFileClip("media/crunching.mp3").subclipped(1, 4)
# Checks it works with videos as well
clip2 = AudioFileClip("media/big_buck_bunny_432_433.webm")
@@ -186,7 +186,7 @@ def test_audioclip_mono_max_volume(mono_wave):
@pytest.mark.parametrize(("nchannels"), (2, 4, 8, 16))
@pytest.mark.parametrize(("channel_muted"), ("left", "right"))
def test_audioclip_stereo_max_volume(nchannels, channel_muted):
- def make_frame(t):
+ def frame_function(t):
frame = []
# build channels (one of each pair muted)
for i in range(int(nchannels / 2)):
@@ -200,7 +200,7 @@ def test_audioclip_stereo_max_volume(nchannels, channel_muted):
frame.append(np.sin(t * 0))
return np.array(frame).T
- clip = AudioClip(make_frame, fps=44100, duration=1)
+ clip = AudioClip(frame_function, fps=44100, duration=1)
max_volume = clip.max_volume(stereo=True)
# if `stereo == True`, `AudioClip.max_volume` returns a Numpy array`
assert isinstance(max_volume, np.ndarray)
diff --git a/tests/test_Clip.py b/tests/test_Clip.py
index 979cabc9..397f228b 100644
--- a/tests/test_Clip.py
+++ b/tests/test_Clip.py
@@ -194,9 +194,9 @@ def test_clip_subclip(duration, start_time, end_time, expected_duration):
if hasattr(expected_duration, "__traceback__"):
with pytest.raises(expected_duration):
- clip.with_subclip(start_time=start_time, end_time=end_time)
+ clip.subclipped(start_time=start_time, end_time=end_time)
else:
- sub_clip = clip.with_subclip(start_time=start_time, end_time=end_time)
+ sub_clip = clip.subclipped(start_time=start_time, end_time=end_time)
assert sub_clip.duration == expected_duration
@@ -232,7 +232,7 @@ def test_clip_subclip(duration, start_time, end_time, expected_duration):
)
def test_clip_cutout(start_time, end_time, expected_frames):
clip = BitmapClip([["RR", "RR"], ["GG", "GG"], ["BB", "BB"]], fps=1)
- new_clip = clip.with_cutout(start_time, end_time)
+ new_clip = clip.with_section_cut_out(start_time, end_time)
assert new_clip == BitmapClip(expected_frames, fps=1)
diff --git a/tests/test_SubtitlesClip.py b/tests/test_SubtitlesClip.py
index e124e0fa..9a8a2124 100644
--- a/tests/test_SubtitlesClip.py
+++ b/tests/test_SubtitlesClip.py
@@ -44,7 +44,7 @@ def test_subtitles(util):
subtitles = SubtitlesClip("media/subtitles.srt", make_textclip=generator)
final = CompositeVideoClip([myvideo, subtitles])
- final.with_subclip(0, 0.5).write_videofile(
+ final.subclipped(0, 0.5).write_videofile(
os.path.join(util.TMP_DIR, "subtitles.mp4"),
fps=5,
logger=None,
diff --git a/tests/test_VideoClip.py b/tests/test_VideoClip.py
index d4189f7f..53c04817 100644
--- a/tests/test_VideoClip.py
+++ b/tests/test_VideoClip.py
@@ -95,7 +95,7 @@ def test_write_frame_errors_with_redirected_logs(util, video):
def test_write_videofiles_with_temp_audiofile_path(util):
- clip = VideoFileClip("media/big_buck_bunny_432_433.webm").with_subclip(0.2, 0.5)
+ clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclipped(0.2, 0.5)
location = os.path.join(util.TMP_DIR, "temp_audiofile_path.webm")
temp_location = os.path.join(util.TMP_DIR, "temp_audiofile")
if not os.path.exists(temp_location):
@@ -183,9 +183,9 @@ def test_write_gif(util, video):
def test_with_sub_effetcs(util):
- clip = VideoFileClip("media/big_buck_bunny_0_30.webm").with_subclip(0, 1)
- new_clip = clip.with_sub_effects([vfx.MultiplySpeed(0.5)])
- location = os.path.join(util.TMP_DIR, "with_sub_effects.mp4")
+ clip = VideoFileClip("media/big_buck_bunny_0_30.webm").subclipped(0, 1)
+ new_clip = clip.with_effects_on_subclip([vfx.MultiplySpeed(0.5)])
+ location = os.path.join(util.TMP_DIR, "with_effects_on_subclip.mp4")
new_clip.write_videofile(location)
assert os.path.isfile(location)
@@ -193,7 +193,7 @@ def test_with_sub_effetcs(util):
def test_oncolor(util):
# It doesn't need to be a ColorClip
clip = ColorClip(size=(100, 60), color=(255, 0, 0), duration=0.5)
- on_color_clip = clip.with_on_color(size=(200, 160), color=(0, 0, 255))
+ on_color_clip = clip.with_background_color(size=(200, 160), color=(0, 0, 255))
location = os.path.join(util.TMP_DIR, "oncolor.mp4")
on_color_clip.write_videofile(location, fps=24)
assert os.path.isfile(location)
@@ -215,8 +215,8 @@ def test_oncolor(util):
def test_setaudio(util):
clip = ColorClip(size=(100, 60), color=(255, 0, 0), duration=0.5)
- make_frame_440 = lambda t: [np.sin(440 * 2 * np.pi * t)]
- audio = AudioClip(make_frame_440, duration=0.5)
+ frame_function_440 = lambda t: [np.sin(440 * 2 * np.pi * t)]
+ audio = AudioClip(frame_function_440, duration=0.5)
audio.fps = 44100
clip = clip.with_audio(audio)
location = os.path.join(util.TMP_DIR, "setaudio.mp4")
@@ -226,7 +226,7 @@ def test_setaudio(util):
def test_setaudio_with_audiofile(util):
clip = ColorClip(size=(100, 60), color=(255, 0, 0), duration=0.5)
- audio = AudioFileClip("media/crunching.mp3").with_subclip(0, 0.5)
+ audio = AudioFileClip("media/crunching.mp3").subclipped(0, 0.5)
clip = clip.with_audio(audio)
location = os.path.join(util.TMP_DIR, "setaudiofile.mp4")
clip.write_videofile(location, fps=24)
@@ -236,26 +236,24 @@ def test_setaudio_with_audiofile(util):
def test_setopacity(util, video):
clip = video(start_time=0.2, end_time=0.6)
clip = clip.with_opacity(0.5)
- clip = clip.with_on_color(size=(1000, 1000), color=(0, 0, 255), col_opacity=0.8)
+ clip = clip.with_background_color(size=(1000, 1000), color=(0, 0, 255), opacity=0.8)
location = os.path.join(util.TMP_DIR, "setopacity.mp4")
clip.write_videofile(location)
assert os.path.isfile(location)
-def test_with_layer():
- bottom_clip = BitmapClip([["ABC"], ["BCA"], ["CAB"]], fps=1).with_layer(1)
- top_clip = BitmapClip([["DEF"], ["EFD"]], fps=1).with_layer(2)
+def test_with_layer_index():
+ bottom_clip = BitmapClip([["ABC"], ["BCA"], ["CAB"]], fps=1).with_layer_index(1)
+ top_clip = BitmapClip([["DEF"], ["EFD"]], fps=1).with_layer_index(2)
composite_clip = CompositeVideoClip([bottom_clip, top_clip])
reversed_composite_clip = CompositeVideoClip([top_clip, bottom_clip])
# Make sure that the order of clips makes no difference to the composite clip
- assert composite_clip.with_subclip(0, 2) == reversed_composite_clip.with_subclip(
- 0, 2
- )
+ assert composite_clip.subclipped(0, 2) == reversed_composite_clip.subclipped(0, 2)
# Make sure that only the 'top' clip is kept
- assert top_clip.with_subclip(0, 2) == composite_clip.with_subclip(0, 2)
+ assert top_clip.subclipped(0, 2) == composite_clip.subclipped(0, 2)
# Make sure that it works even when there is only one clip playing at that time
target_clip = BitmapClip([["DEF"], ["EFD"], ["CAB"]], fps=1)
diff --git a/tests/test_VideoFileClip.py b/tests/test_VideoFileClip.py
index f5337431..db06d460 100644
--- a/tests/test_VideoFileClip.py
+++ b/tests/test_VideoFileClip.py
@@ -52,7 +52,7 @@ def test_copied_videofileclip_write_videofile(util):
input_video_filepath = "media/big_buck_bunny_432_433.webm"
output_video_filepath = os.path.join(util.TMP_DIR, "copied_videofileclip.mp4")
- clip = VideoFileClip(input_video_filepath).with_subclip(0, 1)
+ clip = VideoFileClip(input_video_filepath).subclipped(0, 1)
copied_clip = clip.copy()
copied_clip.write_videofile(output_video_filepath)
diff --git a/tests/test_compositing.py b/tests/test_compositing.py
index 7835e2f4..43018d74 100644
--- a/tests/test_compositing.py
+++ b/tests/test_compositing.py
@@ -16,7 +16,7 @@ class ClipPixelTest:
self.clip = clip
def expect_color_at(self, ts, expected, xy=[0, 0]):
- frame = self.clip.make_frame(ts)
+ frame = self.clip.frame_function(ts)
r, g, b = expected
actual = frame[xy[1]][xy[0]]
diff = abs(actual[0] - r) + abs(actual[1] - g) + abs(actual[2] - b)
diff --git a/tests/test_ffmpeg_reader.py b/tests/test_ffmpeg_reader.py
index 6e132049..d619efcc 100644
--- a/tests/test_ffmpeg_reader.py
+++ b/tests/test_ffmpeg_reader.py
@@ -292,7 +292,7 @@ def test_ffmpeg_parse_video_rotation():
def test_correct_video_rotation(util):
"""See https://github.com/Zulko/moviepy/pull/577"""
- clip = VideoFileClip("media/rotated-90-degrees.mp4").with_subclip(0.2, 0.4)
+ clip = VideoFileClip("media/rotated-90-degrees.mp4").subclipped(0.2, 0.4)
corrected_rotation_filename = os.path.join(
util.TMP_DIR,
diff --git a/tests/test_fx.py b/tests/test_fx.py
index b90aa629..746b8491 100644
--- a/tests/test_fx.py
+++ b/tests/test_fx.py
@@ -1082,8 +1082,8 @@ def test_audio_normalize():
def test_audio_normalize_muted():
z_array = np.array([0.0])
- make_frame = lambda t: z_array
- clip = AudioClip(make_frame, duration=1, fps=44100)
+ frame_function = lambda t: z_array
+ clip = AudioClip(frame_function, duration=1, fps=44100)
clip = clip.with_effects([afx.AudioNormalize()])
assert np.array_equal(clip.to_soundarray(), z_array)
@@ -1173,17 +1173,17 @@ def test_multiply_volume_audioclip(
end_time,
):
if sound_type == "stereo":
- make_frame = lambda t: np.array(
+ frame_function = lambda t: np.array(
[
np.sin(440 * 2 * np.pi * t),
np.sin(160 * 2 * np.pi * t),
]
).T.copy(order="C")
else:
- make_frame = lambda t: [np.sin(440 * 2 * np.pi * t)]
+ frame_function = lambda t: [np.sin(440 * 2 * np.pi * t)]
clip = AudioClip(
- make_frame,
+ frame_function,
duration=duration if duration else 0.1,
fps=22050,
)
@@ -1282,7 +1282,7 @@ def test_multiply_volume_videoclip():
clip = (
VideoFileClip("media/chaplin.mp4")
- .with_subclip(0, 0.3)
+ .subclipped(0, 0.3)
.with_effects(
[
afx.MultiplyVolume(
@@ -1374,7 +1374,7 @@ def test_audio_delay(stereo_wave, duration, offset, n_repeats, decay):
# stereo audio clip
clip = AudioClip(
- make_frame=stereo_wave(left_freq=440, right_freq=880),
+ frame_function=stereo_wave(left_freq=440, right_freq=880),
duration=duration,
fps=44100,
)
@@ -1448,11 +1448,11 @@ def test_audio_fadein(
mono_wave, stereo_wave, sound_type, fps, clip_duration, fadein_duration
):
if sound_type == "stereo":
- make_frame = stereo_wave(left_freq=440, right_freq=160)
+ frame_function = stereo_wave(left_freq=440, right_freq=160)
else:
- make_frame = mono_wave(440)
+ frame_function = mono_wave(440)
- clip = AudioClip(make_frame, duration=clip_duration, fps=fps)
+ clip = AudioClip(frame_function, duration=clip_duration, fps=fps)
new_clip = clip.with_effects([afx.AudioFadeIn(fadein_duration)])
# first frame is muted
@@ -1474,7 +1474,7 @@ def test_audio_fadein(
start_times = np.arange(0, fadein_duration, time_foreach_part)
for i, start_time in enumerate(start_times):
end_time = start_time + time_foreach_part
- subclip_max_volume = new_clip.with_subclip(start_time, end_time).max_volume()
+ subclip_max_volume = new_clip.subclipped(start_time, end_time).max_volume()
possible_value = (i + 1) / n_parts
assert round(subclip_max_volume, 2) in [
@@ -1488,7 +1488,7 @@ def test_audio_fadein(
start_times = np.arange(fadein_duration, clip_duration, time_foreach_part)
for i, start_time in enumerate(start_times):
end_time = start_time + time_foreach_part
- subclip_max_volume = new_clip.with_subclip(start_time, end_time).max_volume()
+ subclip_max_volume = new_clip.subclipped(start_time, end_time).max_volume()
assert round(subclip_max_volume, 4) == 1
@@ -1509,11 +1509,11 @@ def test_audio_fadeout(
mono_wave, stereo_wave, sound_type, fps, clip_duration, fadeout_duration
):
if sound_type == "stereo":
- make_frame = stereo_wave(left_freq=440, right_freq=160)
+ frame_function = stereo_wave(left_freq=440, right_freq=160)
else:
- make_frame = mono_wave(440)
+ frame_function = mono_wave(440)
- clip = AudioClip(make_frame, duration=clip_duration, fps=fps)
+ clip = AudioClip(frame_function, duration=clip_duration, fps=fps)
new_clip = clip.with_effects([afx.AudioFadeOut(fadeout_duration)])
fadeout_duration = convert_to_seconds(fadeout_duration)
@@ -1530,7 +1530,7 @@ def test_audio_fadeout(
)
for i, start_time in enumerate(start_times):
end_time = start_time + time_foreach_part
- subclip_max_volume = new_clip.with_subclip(start_time, end_time).max_volume()
+ subclip_max_volume = new_clip.subclipped(start_time, end_time).max_volume()
possible_value = 1 - i * 0.1
assert round(subclip_max_volume, 2) in [
@@ -1544,7 +1544,7 @@ def test_audio_fadeout(
start_times = np.arange(0, clip_duration - fadeout_duration, time_foreach_part)
for i, start_time in enumerate(start_times):
end_time = start_time + time_foreach_part
- subclip_max_volume = new_clip.with_subclip(start_time, end_time).max_volume()
+ subclip_max_volume = new_clip.subclipped(start_time, end_time).max_volume()
assert round(subclip_max_volume, 4) == 1
diff --git a/tests/test_issues.py b/tests/test_issues.py
index 5665480e..a23354b5 100644
--- a/tests/test_issues.py
+++ b/tests/test_issues.py
@@ -229,7 +229,7 @@ def test_issue_334(util):
avatar.with_mask(maskclip) # must set maskclip here..
concatenated = avatar * 3
- tt = VideoFileClip("media/big_buck_bunny_0_30.webm").with_subclip(0, 3)
+ tt = VideoFileClip("media/big_buck_bunny_0_30.webm").subclipped(0, 3)
# TODO: Setting mask here does not work:
# .with_mask(maskclip).resize(size)])
final = CompositeVideoClip(
@@ -303,13 +303,13 @@ def test_issue_470(util):
audio_clip = AudioFileClip("media/crunching.mp3")
# end_time is out of bounds
- subclip = audio_clip.with_subclip(start_time=6, end_time=9)
+ subclip = audio_clip.subclipped(start_time=6, end_time=9)
with pytest.raises(IOError):
subclip.write_audiofile(wav_filename, write_logfile=True)
# but this one should work..
- subclip = audio_clip.with_subclip(start_time=6, end_time=8)
+ subclip = audio_clip.subclipped(start_time=6, end_time=8)
subclip.write_audiofile(wav_filename, write_logfile=True)
@@ -327,8 +327,8 @@ def test_issue_547():
def test_issue_636():
- with VideoFileClip("media/big_buck_bunny_0_30.webm").with_subclip(0, 11) as video:
- with video.with_subclip(0, 1) as _:
+ with VideoFileClip("media/big_buck_bunny_0_30.webm").subclipped(0, 11) as video:
+ with video.subclipped(0, 1) as _:
pass
@@ -336,9 +336,9 @@ def test_issue_655():
video_file = "media/fire2.mp4"
for subclip in [(0, 2), (1, 2), (2, 3)]:
with VideoFileClip(video_file) as v:
- with v.with_subclip(1, 2) as _:
+ with v.subclipped(1, 2) as _:
pass
- next(v.with_subclip(*subclip).iter_frames())
+ next(v.subclipped(*subclip).iter_frames())
assert True
diff --git a/tests/test_videotools.py b/tests/test_videotools.py
index 28837916..52c4e24a 100644
--- a/tests/test_videotools.py
+++ b/tests/test_videotools.py
@@ -79,7 +79,7 @@ def test_detect_scenes():
def test_find_video_period():
clip = (
VideoFileClip("media/chaplin.mp4")
- .with_subclip(0, 0.5)
+ .subclipped(0, 0.5)
.with_effects([vfx.Loop(2)])
) # fps=25
@@ -303,7 +303,7 @@ def test_FramesMatches_select_scenes(
):
video_clip = VideoFileClip(filename)
if subclip is not None:
- video_clip = video_clip.with_subclip(subclip[0], subclip[1])
+ video_clip = video_clip.subclipped(subclip[0], subclip[1])
clip = concatenate_videoclips(
[video_clip.with_effects([vfx.TimeMirror()]), video_clip]
)
@@ -318,7 +318,7 @@ def test_FramesMatches_select_scenes(
def test_FramesMatches_write_gifs(util):
- video_clip = VideoFileClip("media/chaplin.mp4").with_subclip(0, 0.2)
+ video_clip = VideoFileClip("media/chaplin.mp4").subclipped(0, 0.2)
clip = concatenate_videoclips(
[video_clip.with_effects([vfx.TimeMirror()]), video_clip]
)
@@ -1043,7 +1043,7 @@ def test_Trajectory_from_to_file(util):
id="FakeClip",
),
pytest.param(
- VideoFileClip("media/chaplin.mp4").with_subclip(0, 1),
+ VideoFileClip("media/chaplin.mp4").subclipped(0, 1),
None,
None,
None,
@@ -1088,8 +1088,8 @@ def test_find_audio_period(mono_wave, stereo_wave, wave_type):
wave2 = stereo_wave(left_freq=100, right_freq=200)
clip = CompositeAudioClip(
[
- AudioClip(make_frame=wave1, duration=0.3, fps=22050),
- AudioClip(make_frame=wave2, duration=0.3, fps=22050).with_effects(
+ AudioClip(frame_function=wave1, duration=0.3, fps=22050),
+ AudioClip(frame_function=wave2, duration=0.3, fps=22050).with_effects(
[afx.MultiplyVolume(0, end_time=0.1)]
),
]