Skip to content

Video editing with Python

Rename 'speedx' FX by 'multiply_speed' (#1478)

Álvaro Mondéjarb57640312e73
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bac2832d..ccedb004 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Renamed `cols_widths` argument of `clips_array` function by `cols_heights` [\#1465](https://github.com/Zulko/moviepy/pull/1465)
- `video_nframes` attribute of dictionary returned from `ffmpeg_parse_infos` renamed to `video_n_frames` [\#1471](https://github.com/Zulko/moviepy/pull/1471)
- Renamed `colorx` FX by `multiply_color` [\#1475](https://github.com/Zulko/moviepy/pull/1475)
+- Renamed `speedx` FX by `multiply_speed` [\#1478](https://github.com/Zulko/moviepy/pull/1478)
### Deprecated <!-- for soon-to-be removed features -->
- `moviepy.video.fx.all` and `moviepy.audio.fx.all`. Use the fx method directly from the clip instance or import the fx function from `moviepy.video.fx` and `moviepy.audio.fx`. [\#1105](https://github.com/Zulko/moviepy/pull/1105)
diff --git a/docs/getting_started/effects.rst b/docs/getting_started/effects.rst
index bc844b73..54365849 100644
--- a/docs/getting_started/effects.rst
+++ b/docs/getting_started/effects.rst
@@ -52,7 +52,7 @@ Much better! There are already many effects implemented in the modules ``moviepy
from moviepy import *
clip = (VideoFileClip("myvideo.avi")
.fx( vfx.resize, width=460) # resize (keep aspect ratio)
- .fx( vfx.speedx, 2) # double the speed
+ .fx( vfx.multiply_speed, 2) # double the speed
.fx( vfx.multiply_color, 0.5)) # darken the picture
For convenience, fx methods such as ``resize`` can be called in a simpler way: ``clip.resize(...)`` instead of ``clip.fx( vfx.resize, ...)``
diff --git a/docs/ref/videofx.rst b/docs/ref/videofx.rst
index 0f484fca..2dbf4885 100644
--- a/docs/ref/videofx.rst
+++ b/docs/ref/videofx.rst
@@ -55,11 +55,11 @@ the module ``video.fx`` is loaded as ``vfx`` and you can use ``vfx.multiply_colo
mirror_x
mirror_y
multiply_color
+ multiply_speed
painting
resize
rotate
scroll
- speedx
supersample
time_mirror
time_symmetrize
diff --git a/docs/ref/videofx/moviepy.video.fx.all.colorx.rst b/docs/ref/videofx/moviepy.video.fx.all.multiply_color.rst
similarity index 100%
rename from docs/ref/videofx/moviepy.video.fx.all.colorx.rst
rename to docs/ref/videofx/moviepy.video.fx.all.multiply_color.rst
diff --git a/docs/ref/videofx/moviepy.video.fx.all.multiply_speed.rst b/docs/ref/videofx/moviepy.video.fx.all.multiply_speed.rst
new file mode 100644
index 00000000..559e6098
--- /dev/null
+++ b/docs/ref/videofx/moviepy.video.fx.all.multiply_speed.rst
@@ -0,0 +1,6 @@
+moviepy.video.fx.all.multiply_speed
+===================================
+
+.. currentmodule:: moviepy.video.fx.all
+
+.. autofunction:: multiply_speed
\ No newline at end of file
diff --git a/docs/ref/videofx/moviepy.video.fx.all.speedx.rst b/docs/ref/videofx/moviepy.video.fx.all.speedx.rst
deleted file mode 100644
index 6710d0fe..00000000
--- a/docs/ref/videofx/moviepy.video.fx.all.speedx.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-moviepy.video.fx.all.speedx
-===========================
-
-.. currentmodule:: moviepy.video.fx.all
-
-.. autofunction:: speedx
\ No newline at end of file
diff --git a/moviepy/Clip.py b/moviepy/Clip.py
index 223bfcb0..24292bb9 100644
--- a/moviepy/Clip.py
+++ b/moviepy/Clip.py
@@ -297,9 +297,9 @@ class Clip:
halved in this mode, the duration will be doubled."""
if change_duration:
- from moviepy.video.fx.speedx import speedx
+ from moviepy.video.fx.multiply_speed import multiply_speed
- newclip = speedx(self, fps / self.fps)
+ newclip = multiply_speed(self, fps / self.fps)
else:
newclip = self.copy()
diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py
index 71a1283c..4cd14df8 100644
--- a/moviepy/video/VideoClip.py
+++ b/moviepy/video/VideoClip.py
@@ -523,7 +523,7 @@ class VideoClip(Clip):
slower than the clip you will use ::
>>> # slow down clip 50% and make it a gif
- >>> myClip.speedx(0.5).to_gif('myClip.gif')
+ >>> myClip.multiply_speed(0.5).to_gif('myClip.gif')
"""
# A little sketchy at the moment, maybe move all that in write_gif,
@@ -589,7 +589,7 @@ class VideoClip(Clip):
>>> # 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.speedx(0.5) , 3,6)
+ >>> new_clip = clip.subapply(lambda c:c.multiply_speed(0.5) , 3,6)
"""
left = None if (start_time == 0) else self.subclip(0, start_time)
diff --git a/moviepy/video/fx/__init__.py b/moviepy/video/fx/__init__.py
index 2c6b318b..d1f56ce3 100644
--- a/moviepy/video/fx/__init__.py
+++ b/moviepy/video/fx/__init__.py
@@ -22,11 +22,11 @@ from moviepy.video.fx.mask_or import mask_or
from moviepy.video.fx.mirror_x import mirror_x
from moviepy.video.fx.mirror_y import mirror_y
from moviepy.video.fx.multiply_color import multiply_color
+from moviepy.video.fx.multiply_speed import multiply_speed
from moviepy.video.fx.painting import painting
from moviepy.video.fx.resize import resize
from moviepy.video.fx.rotate import rotate
from moviepy.video.fx.scroll import scroll
-from moviepy.video.fx.speedx import speedx
from moviepy.video.fx.supersample import supersample
from moviepy.video.fx.time_mirror import time_mirror
from moviepy.video.fx.time_symmetrize import time_symmetrize
@@ -55,11 +55,11 @@ __all__ = (
"mirror_x",
"mirror_y",
"multiply_color",
+ "multiply_speed",
"painting",
"resize",
"rotate",
"scroll",
- "speedx",
"supersample",
"time_mirror",
"time_symmetrize",
diff --git a/moviepy/video/fx/speedx.py b/moviepy/video/fx/multiply_speed.py
similarity index 90%
rename from moviepy/video/fx/speedx.py
rename to moviepy/video/fx/multiply_speed.py
index a7446054..ade4894e 100644
--- a/moviepy/video/fx/speedx.py
+++ b/moviepy/video/fx/multiply_speed.py
@@ -1,4 +1,4 @@
-def speedx(clip, factor=None, final_duration=None):
+def multiply_speed(clip, factor=None, final_duration=None):
"""
Returns a clip playing the current clip but at a speed multiplied
by ``factor``. Instead of factor one can indicate the desired
diff --git a/moviepy/video/io/gif_writers.py b/moviepy/video/io/gif_writers.py
index c217e429..097a10b7 100644
--- a/moviepy/video/io/gif_writers.py
+++ b/moviepy/video/io/gif_writers.py
@@ -195,7 +195,7 @@ def write_gif(
slower than the clip you will use ::
>>> # slow down clip 50% and make it a gif
- >>> myClip.speedx(0.5).write_gif('myClip.gif')
+ >>> myClip.multiply_speed(0.5).write_gif('myClip.gif')
"""
diff --git a/tests/test_VideoClip.py b/tests/test_VideoClip.py
index 954361c1..b4ed9acd 100644
--- a/tests/test_VideoClip.py
+++ b/tests/test_VideoClip.py
@@ -8,7 +8,7 @@ from moviepy.audio.AudioClip import AudioClip
from moviepy.audio.io.AudioFileClip import AudioFileClip
from moviepy.utils import close_all_clips
from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
-from moviepy.video.fx.speedx import speedx
+from moviepy.video.fx.multiply_speed import multiply_speed
from moviepy.video.io.VideoFileClip import VideoFileClip
from moviepy.video.VideoClip import BitmapClip, ColorClip, VideoClip
@@ -166,7 +166,7 @@ def test_write_gif_ImageMagick_tmpfiles_pixel_format():
def test_subfx():
clip = VideoFileClip("media/big_buck_bunny_0_30.webm").subclip(0, 1)
- transform = lambda c: speedx(c, 0.5)
+ transform = lambda c: multiply_speed(c, 0.5)
new_clip = clip.subfx(transform, 0.5, 0.8)
location = os.path.join(TMP_DIR, "subfx.mp4")
new_clip.write_videofile(location)
diff --git a/tests/test_fx.py b/tests/test_fx.py
index 25977c72..5779192f 100644
--- a/tests/test_fx.py
+++ b/tests/test_fx.py
@@ -23,9 +23,9 @@ from moviepy.video.fx import (
mirror_x,
mirror_y,
multiply_color,
+ multiply_speed,
resize,
rotate,
- speedx,
time_mirror,
time_symmetrize,
)
@@ -532,22 +532,22 @@ def test_scroll():
pass
-def test_speedx():
+def test_multiply_speed():
clip = BitmapClip([["A"], ["B"], ["C"], ["D"]], fps=1)
- clip1 = speedx(clip, 0.5) # 1/2x speed
+ clip1 = multiply_speed(clip, 0.5) # 1/2x speed
target1 = BitmapClip(
[["A"], ["A"], ["B"], ["B"], ["C"], ["C"], ["D"], ["D"]], fps=1
)
assert clip1 == target1
- clip2 = speedx(clip, final_duration=8) # 1/2x speed
+ clip2 = multiply_speed(clip, final_duration=8) # 1/2x speed
target2 = BitmapClip(
[["A"], ["A"], ["B"], ["B"], ["C"], ["C"], ["D"], ["D"]], fps=1
)
assert clip2 == target2
- clip3 = speedx(clip, final_duration=12) # 1/2x speed
+ clip3 = multiply_speed(clip, final_duration=12) # 1/2x speed
target3 = BitmapClip(
[
["A"],
@@ -567,15 +567,15 @@ def test_speedx():
)
assert clip3 == target3
- clip4 = speedx(clip, 2) # 2x speed
+ clip4 = multiply_speed(clip, 2) # 2x speed
target4 = BitmapClip([["A"], ["C"]], fps=1)
assert clip4 == target4
- clip5 = speedx(clip, final_duration=2) # 2x speed
+ clip5 = multiply_speed(clip, final_duration=2) # 2x speed
target5 = BitmapClip([["A"], ["C"]], fps=1)
assert clip5 == target5
- clip6 = speedx(clip, 4) # 4x speed
+ clip6 = multiply_speed(clip, 4) # 4x speed
target6 = BitmapClip([["A"]], fps=1)
assert (
clip6 == target6