Video editing with Python
add ImageSequenceClip tests (#456)
Billy Earneya152c52c7ae3
diff --git a/tests/download_media.py b/tests/download_media.pynew file mode 100644index 00000000..7a81445f--- /dev/null+++ b/tests/download_media.py@@ -0,0 +1,24 @@+import os++from moviepy.editor import *++def download_url(url, filename):+ if not os.path.exists(filename):+ print("\nDownloading %s\n" % filename)+ download_webfile(url, filename)+ print("Downloading complete...\n")++def download_youtube_video(youtube_id, filename):+ # FYI.. travis-ci doesn't like youtube-dl+ download_url(youtube_id, filename)+++def download():+ if not os.path.exists("media"):+ os.mkdir("media")++ download_url("https://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/Python_logo_and_wordmark.svg/260px-Python_logo_and_wordmark.svg.png",+ "media/python_logo.png")++ download_url("http://matplotlib.org/_images/barh_demo.png",+ "media/matplotlib_demo1.png")diff --git a/tests/test_ImageSequenceClip.py b/tests/test_ImageSequenceClip.pynew file mode 100644index 00000000..79473f33--- /dev/null+++ b/tests/test_ImageSequenceClip.py@@ -0,0 +1,27 @@+import pytest+from moviepy.editor import *++# must have to work on travis-ci+import sys+sys.path.append("tests")+import download_media++def test_download_media(capsys):+ with capsys.disabled():+ download_media.download()++def test_1():+ images=[]+ durations=[]+ for i in range(5):+ durations.append(i)+ images.append("media/python_logo.png")+ durations.append(i)+ images.append("media/matplotlib_demo1.png")++ clip=ImageSequenceClip(images, durations=durations)+ assert clip.duration == sum(durations)+ clip.write_videofile("/tmp/ImageSequenceClip1.mp4", fps=30)++if __name__ == '__main__':+ pytest.main()diff --git a/tests/test_VideoFileClip.py b/tests/test_VideoFileClip.pyindex 3cad16fe..d8f272be 100644--- a/tests/test_VideoFileClip.py+++ b/tests/test_VideoFileClip.py@@ -3,20 +3,20 @@ from moviepy.editor import *import osdef test_setup():- _red = ColorClip((1024,800), col=(255,0,0))- _green = ColorClip((1024,800), col=(0,255,0))- _blue = ColorClip((1024,800), col=(0,0,255))+ red = ColorClip((1024,800), col=(255,0,0))+ green = ColorClip((1024,800), col=(0,255,0))+ blue = ColorClip((1024,800), col=(0,0,255))- _red.fps=_green.fps=_blue.fps=30- _video = clips_array([[_red, _green, _blue]]).set_duration(5)- _video.write_videofile("/tmp/test.mp4")+ red.fps=green.fps=blue.fps=30+ video = clips_array([[red, green, blue]]).set_duration(5)+ video.write_videofile("/tmp/test.mp4")assert os.path.exists("/tmp/test.mp4")- _clip = VideoFileClip("/tmp/test.mp4")- assert _clip.duration == 5- assert _clip.fps == 30- assert _clip.size == [1024*3, 800]+ clip = VideoFileClip("/tmp/test.mp4")+ assert clip.duration == 5+ assert clip.fps == 30+ assert clip.size == [1024*3, 800]if __name__ == '__main__':- pytest.main()+ pytest.main()\ No newline at end of filediff --git a/tests/test_compositing.py b/tests/test_compositing.pyindex 7dd1ee2a..e3cf73f3 100644--- a/tests/test_compositing.py+++ b/tests/test_compositing.py@@ -2,33 +2,33 @@ import pytestfrom moviepy.editor import *def test_clips_array():- _red = ColorClip((1024,800), col=(255,0,0))- _green = ColorClip((1024,800), col=(0,255,0))- _blue = ColorClip((1024,800), col=(0,0,255))+ red = ColorClip((1024,800), col=(255,0,0))+ green = ColorClip((1024,800), col=(0,255,0))+ blue = ColorClip((1024,800), col=(0,0,255))- _video = clips_array([[_red, _green, _blue]])+ video = clips_array([[red, green, blue]])with pytest.raises(ValueError,message="Expecting ValueError (duration not set)"):- _video.resize(width=480).write_videofile("/tmp/test_clips_array.mp4")+ video.resize(width=480).write_videofile("/tmp/test_clips_array.mp4")def test_clips_array():- _red = ColorClip((1024,800), col=(255,0,0))- _green = ColorClip((1024,800), col=(0,255,0))- _blue = ColorClip((1024,800), col=(0,0,255))+ red = ColorClip((1024,800), col=(255,0,0))+ green = ColorClip((1024,800), col=(0,255,0))+ blue = ColorClip((1024,800), col=(0,0,255))- _video = clips_array([[_red, _green, _blue]]).set_duration(5)+ video = clips_array([[red, green, blue]]).set_duration(5)with pytest.raises(AttributeError,message="Expecting ValueError (fps not set)"):- _video.write_videofile("/tmp/test_clips_array.mp4")+ video.write_videofile("/tmp/test_clips_array.mp4")#this one should work correctly- _red.fps=_green.fps=_blue.fps=30- _video = clips_array([[_red, _green, _blue]]).set_duration(5)- _video.write_videofile("/tmp/test_clips_array.mp4")+ red.fps=green.fps=blue.fps=30+ video = clips_array([[red, green, blue]]).set_duration(5)+ video.write_videofile("/tmp/test_clips_array.mp4")if __name__ == '__main__':diff --git a/tests/test_issues.py b/tests/test_issues.pyindex 7bd3cae4..38bf7562 100644--- a/tests/test_issues.py+++ b/tests/test_issues.py@@ -7,46 +7,35 @@ import pytestfrom moviepy.editor import *-def download_url(url, filename):- if not os.path.exists(filename):- print("\nDownloading %s\n" % filename)- download_webfile(url, filename)- print("Downloading complete...\n")--def download_youtube_video(youtube_id, filename):- # FYI.. travis-ci doesn't like youtube-dl- download_url(youtube_id, filename)+# must have to work on travis-ci+import sys+sys.path.append("tests")+import download_mediadef test_download_media(capsys):with capsys.disabled():- #download_youtube_video("zvCvOC2VwDc", "media/knights.mp4")- download_url("https://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/Python_logo_and_wordmark.svg/260px-Python_logo_and_wordmark.svg.png",- "media/python_logo.png")-- #knights=VideoFileClip("media/knights.mp4")- #knights10 = knights.subclip(60,70)-+ download_media.download()def test_issue_145():- _video = ColorClip((800, 600), col=(255,0,0)).set_duration(5)+ video = ColorClip((800, 600), col=(255,0,0)).set_duration(5)with pytest.raises(Exception, message="Expecting Exception"):- _final = concatenate_videoclips([_video], method = 'composite')+ final = concatenate_videoclips([_video], method = 'composite')def test_issue_407():- _red = ColorClip((800, 600), col=(255,0,0)).set_duration(5)- _red.fps=30- assert round(_red.fps) == 30+ red = ColorClip((800, 600), col=(255,0,0)).set_duration(5)+ red.fps=30+ assert round(red.fps) == 30- _green=ColorClip((640, 480), col=(0,255,0)).set_duration(2) #ColorClip has no fps attribute- _blue=ColorClip((640, 480), col=(0,0,255)).set_duration(2) #ColorClip has no fps attribute+ green=ColorClip((640, 480), col=(0,255,0)).set_duration(2) #ColorClip has no fps attribute+ blue=ColorClip((640, 480), col=(0,0,255)).set_duration(2) #ColorClip has no fps attribute- _video=concatenate_videoclips([_red, _green, _blue])- assert _video.fps == _red.fps+ video=concatenate_videoclips([red, green, blue])+ assert video.fps == red.fpsdef test_issue_416():- _green=ColorClip((640, 480), col=(0,255,0)).set_duration(2) #ColorClip has no fps attribute- _video1=concatenate_videoclips([_green])- assert _video1.fps == None+ green=ColorClip((640, 480), col=(0,255,0)).set_duration(2) #ColorClip has no fps attribute+ video1=concatenate_videoclips([green])+ assert video1.fps == Nonedef test_issue_417():# failed in python2