Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_duration():
clip = TextClip('hello world', size=(1280,720), color='white')
clip = clip.set_duration(5) # Changed due to #598.
assert clip.duration == 5
clip.close()
clip2 = clip.fx(blink, d_on=1, d_off=1)
clip2 = clip2.set_duration(5)
assert clip2.duration == 5
close_all_clips(locals())
def test_invert_colors():
clip = get_test_video()
clip1 = invert_colors(clip)
clip1.write_videofile(os.path.join(TMP_DIR, "invert_colors1.webm"))
close_all_clips(locals())
def test_mirror_x():
clip = get_test_video()
clip1 = mirror_x(clip)
clip1.write_videofile(os.path.join(TMP_DIR, "mirror_x1.webm"))
close_all_clips(locals())
def test_speedx():
clip = get_test_video()
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"))
close_all_clips(locals())
def test_lum_contrast():
clip = get_test_video()
clip1 = lum_contrast(clip)
clip1.write_videofile(os.path.join(TMP_DIR, "lum_contrast1.webm"))
close_all_clips(locals())
def test_write_gif_ffmpeg():
clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(0.2, 0.4)
location = os.path.join(TMP_DIR, "ffmpeg_gif.gif")
clip.write_gif(location, program="ffmpeg")
assert os.path.isfile(location)
close_all_clips(locals())
def test_save_frame():
clip = VideoFileClip("media/big_buck_bunny_432_433.webm")
location = os.path.join(TMP_DIR, "save_frame.png")
clip.save_frame(location, t=0.5)
assert os.path.isfile(location)
close_all_clips(locals())
def test_resize():
clip = get_test_video()
clip1 = resize(clip, (460, 720)) # New resolution: (460,720)
assert clip1.size == (460, 720)
clip1.write_videofile(os.path.join(TMP_DIR, "resize1.webm"))
clip2 = resize(clip, 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 = resize(clip, width=800) # height computed automatically.
assert clip3.w == 800
# assert clip3.h == ??
clip3.write_videofile(os.path.join(TMP_DIR, "resize3.webm"))
close_all_clips(locals())
def test_write_gif_imageio():
clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(0.2, 0.8)
location = os.path.join(TMP_DIR, "imageio_gif.gif")
clip.write_gif(location, program="imageio")
assert os.path.isfile(location)
close_all_clips(locals())
def test_PR_306():
assert TextClip.list('font') != []
assert TextClip.list('color') != []
with pytest.raises(Exception):
TextClip.list('blah')
close_all_clips(locals())