forked from Zulko/moviepy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'multiply_stereo_volume' FX; rename 'volumex' to 'multiply_volume' (
- Loading branch information
Showing
15 changed files
with
133 additions
and
53 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
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
6 changes: 6 additions & 0 deletions
6
docs/ref/audiofx/moviepy.audio.fx.all.multiply_stereo_volume.rst
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
moviepy.audio.fx.all.multiply_stereo_volume | ||
=========================================== | ||
|
||
.. currentmodule:: moviepy.audio.fx.all | ||
|
||
.. autofunction:: multiply_stereo_volume |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
moviepy.audio.fx.all.multiply_volume | ||
==================================== | ||
|
||
.. currentmodule:: moviepy.audio.fx.all | ||
|
||
.. autofunction:: multiply_volume |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import numpy as np | ||
|
||
from moviepy.decorators import audio_video_fx | ||
|
||
|
||
@audio_video_fx | ||
def multiply_stereo_volume(clip, left=1, right=1): | ||
""" | ||
For a stereo audioclip, this function enables to change the volume | ||
of the left and right channel separately (with the factors `left` | ||
and `right`). Makes a stereo audio clip in which the volume of left | ||
and right is controllable. | ||
Examples | ||
======== | ||
>>> from moviepy import AudioFileClip | ||
>>> music = AudioFileClip('music.ogg') | ||
>>> audio_r = music.multiply_stereo_volume(left=0, right=1) # mute left channel/s | ||
>>> audio_h = music.multiply_stereo_volume(left=0.5, right=0.5) # half audio | ||
""" | ||
|
||
def stereo_volume(get_frame, t): | ||
frame = get_frame(t) | ||
if len(frame) == 1: # mono | ||
frame *= left if left is not None else right | ||
else: # stereo, stereo surround... | ||
for i in range(len(frame[0])): # odd channels are left | ||
frame[:, i] *= left if i % 2 == 0 else right | ||
return frame | ||
|
||
return clip.transform(stereo_volume, 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from moviepy.decorators import audio_video_fx | ||
|
||
|
||
@audio_video_fx | ||
def multiply_volume(clip, factor): | ||
"""Returns a clip with audio volume multiplied by the | ||
value `factor`. Can be applied to both audio and video clips. | ||
This effect is loaded as a clip method when you use moviepy.editor, | ||
so you can just write ``clip.multiply_volume(2)`` | ||
Examples | ||
--------- | ||
>>> from moviepy import AudioFileClip | ||
>>> music = AudioFileClip('music.ogg') | ||
>>> new_clip = clip.multiply_volume(2) # doubles audio volume | ||
>>> new_clip = clip.multiply_volume(0.5) # half audio | ||
""" | ||
return clip.transform( | ||
lambda get_frame, t: factor * get_frame(t), keep_duration=True | ||
) |
This file was deleted.
Oops, something went wrong.
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