Skip to content

Commit

Permalink
make flake8 happier
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Zulkower committed Nov 20, 2024
1 parent 0db382d commit 2cce9c9
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion moviepy/Effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def apply(self, clip: Clip) -> Clip:
"""Apply the current effect on a clip
Parameters
--------------
----------
clip
The target clip to apply the effect on.
(Internally, MoviePy will always pass a copy of the original clip)
Expand Down
1 change: 1 addition & 0 deletions moviepy/audio/fx/AudioDelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class AudioDelay(Effect):

@audio_video_effect
def apply(self, clip: Clip) -> Clip:
"""Apply the effect to the clip."""
decayments = np.linspace(1, max(0, self.decay), self.n_repeats + 1)
return CompositeAudioClip(
[
Expand Down
1 change: 1 addition & 0 deletions moviepy/audio/fx/AudioFadeIn.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def getter(t, duration):

@audio_video_effect
def apply(self, clip: Clip) -> Clip:
"""Apply the effect to the clip."""
if clip.duration is None:
raise ValueError("Attribute 'duration' not set")

Expand Down
1 change: 1 addition & 0 deletions moviepy/audio/fx/AudioFadeOut.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def getter(t, duration):

@audio_video_effect
def apply(self, clip: Clip) -> Clip:
"""Apply the effect to the clip."""
if clip.duration is None:
raise ValueError("Attribute 'duration' not set")

Expand Down
1 change: 1 addition & 0 deletions moviepy/audio/fx/AudioLoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class AudioLoop(Effect):

@audio_video_effect
def apply(self, clip: Clip) -> Clip:
"""Apply the effect to the clip."""
if self.duration is not None:
self.n_loops = int(self.duration / clip.duration) + 1
return concatenate_audioclips(self.n_loops * [clip]).with_duration(
Expand Down
1 change: 1 addition & 0 deletions moviepy/audio/fx/AudioNormalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class AudioNormalize(Effect):

@audio_video_effect
def apply(self, clip: Clip) -> Clip:
"""Apply the effect to the clip."""
max_volume = clip.max_volume()
if max_volume == 0:
return clip
Expand Down
2 changes: 2 additions & 0 deletions moviepy/audio/fx/MultiplyStereoVolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class MultiplyStereoVolume(Effect):

@audio_video_effect
def apply(self, clip: Clip) -> Clip:
"""Apply the effect to the clip."""

def stereo_volume(get_frame, t):
frame = get_frame(t)
if len(frame) == 1: # mono
Expand Down
1 change: 1 addition & 0 deletions moviepy/audio/fx/MultiplyVolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def multiply_mono_volume(get_frame, t):

@audio_video_effect
def apply(self, clip: Clip) -> Clip:
"""Apply the effect to the clip."""
if self.start_time is None and self.end_time is None:
return clip.transform(
lambda get_frame, t: self.factor * get_frame(t),
Expand Down
43 changes: 18 additions & 25 deletions moviepy/audio/io/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class FFMPEG_AudioReader:
nbytes
Desired number of bytes (1,2,4) in the signal that will be
received from ffmpeg
"""

def __init__(
Expand Down Expand Up @@ -122,25 +121,21 @@ def initialize(self, start_time=0):
self.pos = np.round(self.fps * start_time)

def skip_chunk(self, chunksize):
"""
This method skips a chunk of audio data by reading and discarding
the specified number of frames from the audio stream. The audio
stream is read from the `proc` stdout. After skipping the chunk, the
`pos` attribute is updated accordingly.
"""Skip a chunk of audio data by reading and discarding the specified number of
frames from the audio stream. The audio stream is read from the `proc` stdout.
After skipping the chunk, the `pos` attribute is updated accordingly.
Parameters
-----------
chunksize (int): The number of audio frames to skip.
----------
chunksize (int):
The number of audio frames to skip.
"""
_ = self.proc.stdout.read(self.nchannels * chunksize * self.nbytes)
self.proc.stdout.flush()
self.pos = self.pos + chunksize

def read_chunk(self, chunksize):
"""
Reads a chunk of audio data from the audio stream.
"""Read a chunk of audio data from the audio stream.
This method reads a chunk of audio data from the audio stream. The
specified number of frames, given by `chunksize`, is read from the
Expand All @@ -150,9 +145,10 @@ def read_chunk(self, chunksize):
portion is padded with zeros, ensuring that the returned array has
the desired length. The `pos` attribute is updated accordingly.
Parameters:
------------
chunksize (float): The desired number of audio frames to read.
Parameters
----------
chunksize (float):
The desired number of audio frames to read.
"""
# chunksize is not being autoconverted from float to int
Expand Down Expand Up @@ -196,12 +192,12 @@ def get_frame(self, tt):
"""Retrieves the audio frame(s) corresponding to the given timestamp(s).
Parameters
-----------
tt (float or numpy.ndarray): The timestamp(s) at which to retrieve the
audio frame(s). If `tt` is a single float value, the frame corresponding
to that timestamp is returned. If `tt` is a NumPy array of timestamps,
an array of frames corresponding to each timestamp is returned.
----------
tt (float or numpy.ndarray):
The timestamp(s) at which to retrieve the audio frame(s).
If `tt` is a single float value, the frame corresponding to that
timestamp is returned. If `tt` is a NumPy array of timestamps, an
array of frames corresponding to each timestamp is returned.
"""
if isinstance(tt, np.ndarray):
# lazy implementation, but should not cause problems in
Expand Down Expand Up @@ -263,10 +259,7 @@ def get_frame(self, tt):
return self.buffer[ind - self.buffer_startframe]

def buffer_around(self, frame_number):
"""
Fills the buffer with frames, centered on ``frame_number``
if possible
"""
"""Fills the buffer with frames, centered on ``frame_number``if possible"""
# start-frame for the buffer
new_bufferstart = max(0, frame_number - self.buffersize // 2)

Expand Down

0 comments on commit 2cce9c9

Please sign in to comment.