-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
47 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
from moviepy.decorators import audio_video_fx | ||
import numpy as np | ||
|
||
@audio_video_fx | ||
def audio_fadein(clip, duration): | ||
""" Return an audio (or video) clip that is first mute, then the | ||
sound arrives progressively over ``duration`` seconds. """ | ||
fading = lambda gf, t: min(1.0 * t / duration, 1) * gf(t) | ||
def fading(gf,t): | ||
gft = gf(t) | ||
|
||
if np.isscalar(t): | ||
factor = min(1.0 * t / duration, 1) | ||
factor = np.array([factor,factor]) | ||
else: | ||
factor = np.minimum(1.0 * t / duration, 1).T | ||
factor = np.vstack([factor.T,factor.T]).T | ||
return factor * gft | ||
return clip.fl(fading, keep_duration = True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
from moviepy.decorators import audio_video_fx, requires_duration | ||
import numpy as np | ||
|
||
@audio_video_fx | ||
@requires_duration | ||
def audio_fadeout(self, duration): | ||
""" Return a sound clip where the sound fades out progressively | ||
over ``duration`` seconds at the end of the clip. """ | ||
fading = lambda gf, t: max( | ||
fading = lambda gf, t: np.maximum( | ||
1.0 * (self.duration - t) / duration, 0) * gf(t) | ||
return self.fl(fading, keep_duration = True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters