Skip to content

Video editing with Python

make flake8 happier

Valentin Zulkower0201fec56964
diff --git a/moviepy/audio/io/readers.py b/moviepy/audio/io/readers.py
index 0b1012f3..3c0e0974 100644
--- a/moviepy/audio/io/readers.py
+++ b/moviepy/audio/io/readers.py
@@ -11,8 +11,7 @@ from moviepy.video.io.ffmpeg_reader import ffmpeg_parse_infos
class FFMPEG_AudioReader:
- """
- A class to read the audio in either video files or audio files
+ """A class to read the audio in either video files or audio files
using ffmpeg. ffmpeg will read any audio and transform them into
raw data.
@@ -172,8 +171,7 @@ class FFMPEG_AudioReader:
return result
def seek(self, pos):
- """
- Reads a frame at time t. Note for coders: getting an arbitrary
+ """Read a frame at time t. Note for coders: getting an arbitrary
frame in the video with ffmpeg can be painfully slow if some
decoding has to be done. This function tries to avoid fectching
arbitrary frames whenever possible, by moving between adjacent
@@ -189,7 +187,7 @@ class FFMPEG_AudioReader:
self.pos = pos
def get_frame(self, tt):
- """Retrieves the audio frame(s) corresponding to the given timestamp(s).
+ """Retrieve the audio frame(s) corresponding to the given timestamp(s).
Parameters
----------
@@ -259,7 +257,7 @@ class FFMPEG_AudioReader:
return self.buffer[ind - self.buffer_startframe]
def buffer_around(self, frame_number):
- """Fills the buffer with frames, centered on ``frame_number``if possible"""
+ """Fill the buffer with frames, centered on frame_number if possible."""
# start-frame for the buffer
new_bufferstart = max(0, frame_number - self.buffersize // 2)
diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py
index e262ef69..9c775555 100644
--- a/moviepy/video/VideoClip.py
+++ b/moviepy/video/VideoClip.py
@@ -681,7 +681,7 @@ class VideoClip(Clip):
The resulting array with the filled shape is returned.
Parameters
- ------------
+ ----------
pre_array (numpy.ndarray)
The original array to be filled.
diff --git a/moviepy/video/fx/Crop.py b/moviepy/video/fx/Crop.py
index 81e7f502..ed0f8fc4 100644
--- a/moviepy/video/fx/Crop.py
+++ b/moviepy/video/fx/Crop.py
@@ -6,20 +6,10 @@ from moviepy.Effect import Effect
@dataclass
class Crop(Effect):
- x1: int = None
- y1: int = None
- x2: int = None
- y2: int = None
- width: int = None
- height: int = None
- x_center: int = None
- y_center: int = None
-
- """
- Returns a new clip in which just a rectangular subregion of the
- original clip is conserved. x1,y1 indicates the top left corner and
- x2,y2 is the lower right corner of the croped region.
- All coordinates are in pixels. Float numbers are accepted.
+ """Effect to crop a clip to get a new clip in which just a rectangular
+ subregion of the original clip is conserved. `x1,y1` indicates the top left
+ corner and `x2,y2` is the lower right corner of the cropped region. All
+ coordinates are in pixels. Float numbers are accepted.
To crop an arbitrary rectangle:
@@ -44,6 +34,15 @@ class Crop(Effect):
"""
+ x1: int = None
+ y1: int = None
+ x2: int = None
+ y2: int = None
+ width: int = None
+ height: int = None
+ x_center: int = None
+ y_center: int = None
+
def apply(self, clip: Clip) -> Clip:
"""Apply the effect to the clip."""
if self.width and self.x1 is not None:
diff --git a/moviepy/video/fx/Resize.py b/moviepy/video/fx/Resize.py
index a7baa5d1..3f1ddfa7 100644
--- a/moviepy/video/fx/Resize.py
+++ b/moviepy/video/fx/Resize.py
@@ -10,7 +10,7 @@ from moviepy.Effect import Effect
@dataclass
class Resize(Effect):
- """Returns a video clip that is a resized version of the clip.
+ """Effect returning a video clip that is a resized version of the clip.
Parameters
----------
@@ -44,6 +44,7 @@ class Resize(Effect):
apply_to_mask: bool = True
def resizer(self, pic, new_size):
+ """Resize the image using PIL."""
new_size = list(map(int, new_size))
pil_img = Image.fromarray(pic)
resized_pil = pil_img.resize(new_size, Image.Resampling.LANCZOS)
diff --git a/moviepy/video/fx/Scroll.py b/moviepy/video/fx/Scroll.py
index e7b17e2f..1d469d11 100644
--- a/moviepy/video/fx/Scroll.py
+++ b/moviepy/video/fx/Scroll.py
@@ -2,6 +2,24 @@ from moviepy.Effect import Effect
class Scroll(Effect):
+ """Effect that scrolls horizontally or vertically a clip, e.g. to make end credits
+
+ Parameters
+ ----------
+ w, h
+ The width and height of the final clip. Default to clip.w and clip.h
+
+ x_speed, y_speed
+ The speed of the scroll in the x and y directions.
+
+ x_start, y_start
+ The starting position of the scroll in the x and y directions.
+
+
+ apply_to
+ Whether to apply the effect to the mask too.
+ """
+
def __init__(
self,
w=None,
@@ -12,23 +30,7 @@ class Scroll(Effect):
y_start=0,
apply_to="mask",
):
- """
- Scrolls horizontally or vertically a clip, e.g. to make end credits
-
- Parameters
- ----------
-
- w, h
- The width and height of the final clip. Default to clip.w and clip.h
-
- x_speed, y_speed
-
- x_start, y_start
-
-
- apply_to
- """
self.w = w
self.h = h
self.x_speed = x_speed