Skip to content

Commit

Permalink
Add test for videoclip volume transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed May 21, 2021
1 parent 83149e8 commit 60037d8
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/test_fx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ def test_audio_normalize_muted():
),
),
)
def test_multiply_volume(sound_type, factor, duration, start, end):
def test_multiply_volume_audioclip(sound_type, factor, duration, start, end):
if sound_type == "stereo":
make_frame = lambda t: np.array(
[
Expand Down Expand Up @@ -1281,6 +1281,29 @@ def test_multiply_volume(sound_type, factor, duration, start, end):
)


def test_multiply_volume_videoclip():
start, end = (0.1, 0.2)

clip = multiply_volume(
VideoFileClip("media/chaplin.mp4").subclip(0, 0.3),
0,
start=start,
end=end,
)
clip_soundarray = clip.audio.to_soundarray()

assert len(clip_soundarray)

expected_silence = np.zeros(clip_soundarray.shape[1])

for i, frame in enumerate(clip_soundarray):
t = i / clip.audio.fps
if start <= t <= end:
assert np.array_equal(frame, expected_silence)
else:
assert not np.array_equal(frame, expected_silence)


def test_multiply_stereo_volume():
clip = AudioFileClip("media/crunching.mp3")

Expand Down

0 comments on commit 60037d8

Please sign in to comment.