Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for most fx functions #545

Merged
57 commits merged into from Aug 16, 2017
Merged
Changes from 56 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
66bac76
add coveralls to travis.yml
bearney74 Feb 27, 2017
a79a9d2
add coveralls python module
bearney74 Feb 27, 2017
7fd06d8
add pytest-cov python module
bearney74 Feb 27, 2017
0b8c918
add pytest-cov python module
bearney74 Feb 27, 2017
ebbe115
add pytest-cov python module
bearney74 Feb 27, 2017
d8dd159
add coverage
bearney74 Feb 27, 2017
d4c63c8
modify .coverage
bearney74 Feb 27, 2017
06bb874
travis
bearney74 Feb 27, 2017
c3834c6
remove coverage
bearney74 Feb 27, 2017
58d79d6
remove coverage
bearney74 Feb 27, 2017
132ae40
remove coverage
bearney74 Feb 27, 2017
d42e6e0
remove coverage
bearney74 Feb 27, 2017
9681d26
remove coverage
bearney74 Feb 27, 2017
f516d94
remove coverage
bearney74 Feb 27, 2017
5321235
remove coverage
bearney74 Feb 27, 2017
f417b85
remove coverage
bearney74 Feb 27, 2017
b56d21a
remove coverage
bearney74 Feb 27, 2017
cb40ca9
remove coverage
bearney74 Feb 27, 2017
943f33a
remove coverage
bearney74 Feb 27, 2017
73f986e
remove coverage
bearney74 Feb 27, 2017
e481f81
__init__.py needed for pytest-cov and coverage to play nicely
bearney74 Feb 27, 2017
e9b7940
change concatenation to concatenate_videoclips
bearney74 Feb 27, 2017
a97dba9
test tools
bearney74 Feb 28, 2017
a5f142b
add test for clips_array
bearney74 Feb 28, 2017
902256f
update travis to use Trusty
bearney74 Feb 28, 2017
4040ba4
add ffmpeg repo
bearney74 Feb 28, 2017
9230a57
fix typo
bearney74 Feb 28, 2017
d2f706f
add another repo
bearney74 Feb 28, 2017
e3106fe
add -y flag to add-apt-repository
bearney74 Feb 28, 2017
d3a0c24
install ppa-purge
bearney74 Feb 28, 2017
b512261
try another ffmpeg repo
bearney74 Feb 28, 2017
c32cf85
add -y flag
bearney74 Feb 28, 2017
a662e4f
add -qq flag
bearney74 Feb 28, 2017
56a362c
add -qq flag
bearney74 Feb 28, 2017
02fea19
resolve merge issues in test_tools.py
bearney74 Feb 28, 2017
1594b30
add VideoFileClip tests
bearney74 Feb 28, 2017
ecd4090
Merge branch 'master' of github.com:earney/moviepy into tests
bearney74 Feb 28, 2017
c1b097b
put media download logic into its own file
bearney74 Mar 2, 2017
2466574
put media download logic into its own file
bearney74 Mar 2, 2017
77f455e
add download_media.py
bearney74 Mar 2, 2017
95ee94e
update search path
bearney74 Mar 2, 2017
64a2e33
update search path
bearney74 Mar 2, 2017
b073a7a
update search path
bearney74 Mar 2, 2017
7b7cb43
update search path
bearney74 Mar 2, 2017
3fe39cb
update search path
bearney74 Mar 2, 2017
f60bf65
remove undescore from local variables
bearney74 Mar 2, 2017
58a78cc
add TextClip test
bearney74 Mar 6, 2017
297fe19
add comment tabout ImageMagick errors in Travis
bearney74 Mar 6, 2017
9c8ce04
add comment tabout ImageMagick errors in Travis
bearney74 Mar 6, 2017
f434334
fix resolve issue
bearney74 Mar 6, 2017
18386fe
Merge branch 'master' of github.com:Zulko/moviepy into tests
bearney74 Apr 14, 2017
403c0d8
add tests for most fx functions
bearney74 Apr 14, 2017
ab1d032
fix test_fx.py main
bearney74 Apr 14, 2017
599b2b5
Merge branch 'master' of github.com:Zulko/moviepy into tests
bearney74 Apr 14, 2017
a8efa4a
import make_loopable module
bearney74 Apr 14, 2017
d1ca8bc
Merge branch 'master' into tests
bearney74 Apr 19, 2017
7e0d61c
Merge branch 'master' into tests
bearney74 Aug 16, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.video.io.VideoFileClip import VideoFileClip

import download_media
Expand Down Expand Up @@ -67,6 +79,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"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you figure out these issues?


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"))


if __name__ == '__main__':
pytest.main()