Skip to content

Commit

Permalink
Speed up 'AudioClip.to_soundarray'
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed Jan 16, 2021
1 parent 646674c commit 1844fe1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions moviepy/audio/AudioClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ def to_soundarray(
2 for 16bit, 4 for 32bit sound.
"""
if fps is None:
fps = self.fps

stacker = np.vstack if self.nchannels == 2 else np.hstack
max_duration = 1.0 * buffersize / fps
if tt is None:
if fps is None:
fps = self.fps

max_duration = 1 * buffersize / fps
if self.duration > max_duration:
stacker = np.vstack if self.nchannels == 2 else np.hstack
return stacker(
tuple(
self.iter_chunks(
Expand Down

0 comments on commit 1844fe1

Please sign in to comment.