Skip to content

Commit

Permalink
add tests for most fx functions (#545)
Browse files Browse the repository at this point in the history
* add coveralls to travis.yml

* add coveralls python module

* add pytest-cov python module

* add pytest-cov python module

* add pytest-cov python module

* add coverage

* modify .coverage

* travis

* remove coverage

* remove coverage

* remove coverage

* remove coverage

* remove coverage

* remove coverage

* remove coverage

* remove coverage

* remove coverage

* remove coverage

* remove coverage

* remove coverage

* __init__.py needed for pytest-cov and coverage to play nicely

* change concatenation to concatenate_videoclips

*  test tools

* add test for clips_array

* update travis to use Trusty

* add ffmpeg repo

* fix typo

* add another repo

* add -y flag to add-apt-repository

* install ppa-purge

* try another ffmpeg repo

* add -y flag

* add -qq flag

* add -qq flag

* add VideoFileClip tests

* put media download logic into its own file

* put media download logic into its own file

* add download_media.py

* update search path

* update search path

* update search path

* update search path

* update search path

* remove undescore from local variables

* add TextClip test

* add comment tabout ImageMagick errors in Travis

* add comment tabout ImageMagick errors in Travis

* add tests for most fx functions

* fix test_fx.py main

* import make_loopable module
  • Loading branch information
bearney74 committed Aug 16, 2017
1 parent 5a3cb6e commit b2c5909
Showing 1 changed file with 151 additions and 0 deletions.
151 changes: 151 additions & 0 deletions tests/test_fx.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
from moviepy.video.fx.crop import crop
from moviepy.video.fx.fadein import fadein
from moviepy.video.fx.fadeout import fadeout
from moviepy.video.fx.invert_colors import invert_colors
from moviepy.video.fx.loop import loop
from moviepy.video.fx.lum_contrast import lum_contrast
from moviepy.video.fx.make_loopable import make_loopable
from moviepy.video.fx.margin import margin
from moviepy.video.fx.mirror_x import mirror_x
from moviepy.video.fx.mirror_y import mirror_y
from moviepy.video.fx.resize import resize
from moviepy.video.fx.rotate import rotate
from moviepy.video.fx.speedx import speedx
from moviepy.video.fx.time_mirror import time_mirror
from moviepy.video.fx.time_symmetrize import time_symmetrize
from moviepy.audio.fx.audio_normalize import audio_normalize
from moviepy.audio.io.AudioFileClip import AudioFileClip
from moviepy.video.io.VideoFileClip import VideoFileClip
Expand Down Expand Up @@ -69,6 +81,145 @@ def test_fadeout():
clip1 = fadeout(clip, 1)
clip1.write_videofile(os.path.join(TMP_DIR,"fadeout1.webm"))

def test_invert_colors():
clip = VideoFileClip("media/big_buck_bunny_432_433.webm")
clip1 = invert_colors(clip)
clip1.write_videofile(os.path.join(TMP_DIR, "invert_colors1.webm"))

def test_loop():
#these do not work.. what am I doing wrong??
return

clip = VideoFileClip("media/big_buck_bunny_432_433.webm")
clip1 = clip.loop() #infinite looping
clip1.write_videofile(os.path.join(TMP_DIR, "loop1.webm"))

clip2 = clip.loop(duration=10) #loop for 10 seconds
clip2.write_videofile(os.path.join(TMP_DIR, "loop2.webm"))

clip3 = clip.loop(n=3) #loop 3 times
clip3.write_videofile(os.path.join(TMP_DIR, "loop3.webm"))

def test_lum_contrast():
clip = VideoFileClip("media/big_buck_bunny_432_433.webm")
clip1 = lum_contrast(clip)
clip1.write_videofile(os.path.join(TMP_DIR, "lum_contrast1.webm"))

#what are the correct value ranges for function arguments lum,
#contrast and contrast_thr? Maybe we should check for these in
#lum_contrast.

def test_make_loopable():
clip = VideoFileClip("media/big_buck_bunny_0_30.webm").subclip(0,10)
clip1 = make_loopable(clip, 1)
clip1.write_videofile(os.path.join(TMP_DIR, "make_loopable1.webm"))

def test_margin():
clip = VideoFileClip("media/big_buck_bunny_432_433.webm")
clip1 = margin(clip) #does the default values change anything?
clip1.write_videofile(os.path.join(TMP_DIR, "margin1.webm"))

clip2 = margin(clip, mar=100) # all margins are 100px
clip2.write_videofile(os.path.join(TMP_DIR, "margin2.webm"))

clip3 = margin(clip, mar=100, color=(255,0,0)) #red margin
clip3.write_videofile(os.path.join(TMP_DIR, "margin3.webm"))

def test_mask_and():
pass

def test_mask_color():
pass

def test_mask_or():
pass

def test_mirror_x():
clip = VideoFileClip("media/big_buck_bunny_432_433.webm")
clip1 = mirror_x(clip)
clip1.write_videofile(os.path.join(TMP_DIR, "mirror_x1.webm"))

def test_mirror_y():
clip = VideoFileClip("media/big_buck_bunny_432_433.webm")
clip1 = mirror_y(clip)
clip1.write_videofile(os.path.join(TMP_DIR, "mirror_y1.webm"))

def test_painting():
pass

def test_resize():
clip = VideoFileClip("media/big_buck_bunny_432_433.webm")

clip1=clip.resize( (460,720) ) # New resolution: (460,720)
assert clip1.size == (460,720)
clip1.write_videofile(os.path.join(TMP_DIR, "resize1.webm"))

clip2=clip.resize(0.6) # width and heigth multiplied by 0.6
assert clip2.size == (clip.size[0]*0.6, clip.size[1]*0.6)
clip2.write_videofile(os.path.join(TMP_DIR, "resize2.webm"))

clip3=clip.resize(width=800) # height computed automatically.
assert clip3.w == 800
#assert clip3.h == ??
clip3.write_videofile(os.path.join(TMP_DIR, "resize3.webm"))

#I get a general stream error when playing this video.
#clip4=clip.resize(lambda t : 1+0.02*t) # slow swelling of the clip
#clip4.write_videofile(os.path.join(TMP_DIR, "resize4.webm"))

def test_rotate():
clip = VideoFileClip("media/big_buck_bunny_432_433.webm")

clip1=rotate(clip, 90) # rotate 90 degrees
assert clip1.size == (clip.size[1], clip.size[0])
clip1.write_videofile(os.path.join(TMP_DIR, "rotate1.webm"))

clip2=rotate(clip, 180) # rotate 90 degrees
assert clip2.size == tuple(clip.size)
clip2.write_videofile(os.path.join(TMP_DIR, "rotate2.webm"))

clip3=rotate(clip, 270) # rotate 90 degrees
assert clip3.size == (clip.size[1], clip.size[0])
clip3.write_videofile(os.path.join(TMP_DIR, "rotate3.webm"))

clip4=rotate(clip, 360) # rotate 90 degrees
assert clip4.size == tuple(clip.size)
clip4.write_videofile(os.path.join(TMP_DIR, "rotate4.webm"))

def test_scroll():
pass

def test_speedx():
clip = VideoFileClip("media/big_buck_bunny_432_433.webm")

clip1=speedx(clip, factor=0.5) # 1/2 speed
assert clip1.duration == 2
clip1.write_videofile(os.path.join(TMP_DIR, "speedx1.webm"))

clip2=speedx(clip, final_duration=2) # 1/2 speed
assert clip2.duration == 2
clip2.write_videofile(os.path.join(TMP_DIR, "speedx2.webm"))

clip2=speedx(clip, final_duration=3) # 1/2 speed
assert clip2.duration == 3
clip2.write_videofile(os.path.join(TMP_DIR, "speedx3.webm"))

def test_supersample():
pass

def test_time_mirror():
clip = VideoFileClip("media/big_buck_bunny_432_433.webm")

clip1=time_mirror(clip)
assert clip1.duration == clip.duration
clip1.write_videofile(os.path.join(TMP_DIR, "time_mirror1.webm"))

def test_time_symmetrize():
clip = VideoFileClip("media/big_buck_bunny_432_433.webm")

clip1=time_symmetrize(clip)
clip1.write_videofile(os.path.join(TMP_DIR, "time_symmetrize1.webm"))

def test_normalize():
clip = AudioFileClip('media/crunching.mp3')
clip = audio_normalize(clip)
Expand Down

0 comments on commit b2c5909

Please sign in to comment.