Пример #1
0
def test_write_image_sequence():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(0.2, 0.5)
    locations = clip.write_images_sequence(
            os.path.join(TMP_DIR, "frame%02d.png"))
    for location in locations:
        assert os.path.isfile(location)
    close_all_clips(locals())
Пример #2
0
def test_subtitles():
    red = ColorClip((800, 600), color=(255, 0, 0)).set_duration(10)
    green = ColorClip((800, 600), color=(0, 255, 0)).set_duration(10)
    blue = ColorClip((800, 600), color=(0, 0, 255)).set_duration(10)
    myvideo = concatenate_videoclips([red, green, blue])
    assert myvideo.duration == 30

    generator = lambda txt: TextClip(txt, font=FONT,
                                     size=(800, 600), fontsize=24,
                                     method='caption', align='South',
                                     color='white')

    subtitles = SubtitlesClip("media/subtitles1.srt", generator)
    final = CompositeVideoClip([myvideo, subtitles])
    final.write_videofile(os.path.join(TMP_DIR, "subtitles1.mp4"), fps=30)

    data = [([0.0, 4.0], 'Red!'), ([5.0, 9.0], 'More Red!'),
            ([10.0, 14.0], 'Green!'), ([15.0, 19.0], 'More Green!'),
            ([20.0, 24.0], 'Blue'), ([25.0, 29.0], 'More Blue!')]

    assert subtitles.subtitles == data

    subtitles = SubtitlesClip(data, generator)
    assert subtitles.subtitles == data
    close_all_clips(locals())
Пример #3
0
def test_toimageclip():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(0.2, 0.6)
    clip = clip.to_ImageClip(t=0.1, duration=0.4)
    location = os.path.join(TMP_DIR, "toimageclip.mp4")
    clip.write_videofile(location, fps=24)
    assert os.path.isfile(location)
    close_all_clips(locals())
Пример #4
0
def test_time_mirror():
    clip = get_test_video()

    clip1 = time_mirror(clip)
    assert clip1.duration == clip.duration
    clip1.write_videofile(os.path.join(TMP_DIR, "time_mirror1.webm"))
    close_all_clips(locals())
Пример #5
0
def test_setaudio_with_audiofile():
    clip = ColorClip(size=(100, 60), color=(255, 0, 0), duration=0.5)
    audio = AudioFileClip("media/crunching.mp3").subclip(0, 0.5)
    clip = clip.set_audio(audio)
    location = os.path.join(TMP_DIR, "setaudiofile.mp4")
    clip.write_videofile(location, fps=24)
    assert os.path.isfile(location)
    close_all_clips(locals())
Пример #6
0
def test_subfx():
    clip = VideoFileClip("media/big_buck_bunny_0_30.webm").subclip(0, 1)
    transform = lambda c: speedx(c, 0.5)
    new_clip = clip.subfx(transform, 0.5, 0.8)
    location = os.path.join(TMP_DIR, "subfx.mp4")
    new_clip.write_videofile(location)
    assert os.path.isfile(location)
    close_all_clips(locals())
Пример #7
0
def test_oncolor():
    # It doesn't need to be a ColorClip
    clip = ColorClip(size=(100, 60), color=(255, 0, 0), duration=0.5)
    on_color_clip = clip.on_color(size=(200, 160), color=(0, 0, 255))
    location = os.path.join(TMP_DIR, "oncolor.mp4")
    on_color_clip.write_videofile(location, fps=24)
    assert os.path.isfile(location)
    close_all_clips(locals())
Пример #8
0
def test_PR_306():

    assert TextClip.list("font") != []
    assert TextClip.list("color") != []

    with pytest.raises(Exception):
        TextClip.list("blah")
    close_all_clips(locals())
Пример #9
0
def test_audio_normalize_muted():
    z_array = np.array([0.0])
    make_frame = lambda t: z_array
    clip = AudioClip(make_frame, duration=1, fps=44100)
    clip = audio_normalize(clip)
    assert np.array_equal(clip.to_soundarray(), z_array)

    close_all_clips(locals())
Пример #10
0
def test_oncolor():
    # It doesn't need to be a ColorClip
    clip = ColorClip(size=(100, 60), color=(255, 0, 0), duration=0.5)
    on_color_clip = clip.on_color(size=(200, 160), color=(0, 0, 255))
    location = os.path.join(TMP_DIR, "oncolor.mp4")
    on_color_clip.write_videofile(location, fps=24)
    assert os.path.isfile(location)
    close_all_clips(locals())
Пример #11
0
def test_PR_306():

    assert TextClip.list('font') != []
    assert TextClip.list('color') != []

    with pytest.raises(Exception, message="Expecting Exception"):
        TextClip.list('blah')
    close_all_clips(locals())
def test_issue_285():

    clip_1, clip_2, clip_3 = ImageClip('media/python_logo.png', duration=10), \
        ImageClip('media/python_logo.png', duration=10), \
        ImageClip('media/python_logo.png', duration=10)
    merged_clip = concatenate_videoclips([clip_1, clip_2, clip_3])
    assert merged_clip.duration == 30
    close_all_clips(locals())
Пример #13
0
def test_setaudio_with_audiofile():
    clip = ColorClip(size=(100, 60), color=(255, 0, 0), duration=0.5)
    audio = AudioFileClip("media/crunching.mp3").subclip(0, 0.5)
    clip = clip.set_audio(audio)
    location = os.path.join(TMP_DIR, "setaudiofile.mp4")
    clip.write_videofile(location, fps=24)
    assert os.path.isfile(location)
    close_all_clips(locals())
Пример #14
0
def test_setopacity():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(0.2, 0.6)
    clip = clip.set_opacity(0.5)
    clip = clip.on_color(size=(1000, 1000), color=(0, 0, 255), col_opacity=0.8)
    location = os.path.join(TMP_DIR, "setopacity.mp4")
    clip.write_videofile(location)
    assert os.path.isfile(location)
    close_all_clips(locals())
Пример #15
0
def test_setopacity():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(0.2, 0.6)
    clip = clip.set_opacity(0.5)
    clip = clip.on_color(size=(1000, 1000), color=(0, 0, 255), col_opacity=0.8)
    location = os.path.join(TMP_DIR, "setopacity.mp4")
    clip.write_videofile(location)
    assert os.path.isfile(location)
    close_all_clips(locals())
Пример #16
0
def test_write_image_sequence():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(
        0.2, 0.24)
    locations = clip.write_images_sequence(
        os.path.join(TMP_DIR, "frame%02d.png"))
    for location in locations:
        assert os.path.isfile(location)
    close_all_clips(locals())
Пример #17
0
def test_issue_285():

    clip_1, clip_2, clip_3 = ImageClip('media/python_logo.png', duration=10), \
        ImageClip('media/python_logo.png', duration=10), \
        ImageClip('media/python_logo.png', duration=10)
    merged_clip = concatenate_videoclips([clip_1, clip_2, clip_3])
    assert merged_clip.duration == 30
    close_all_clips(locals())
Пример #18
0
def test_subfx():
    clip = VideoFileClip("media/big_buck_bunny_0_30.webm").subclip(0, 1)
    transform = lambda c: speedx(c, 0.5)
    new_clip = clip.subfx(transform, 0.5, 0.8)
    location = os.path.join(TMP_DIR, "subfx.mp4")
    new_clip.write_videofile(location)
    assert os.path.isfile(location)
    close_all_clips(locals())
Пример #19
0
def test_check_codec():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm")
    location = os.path.join(TMP_DIR, "not_a_video.mas")
    try:
        clip.write_videofile(location)
    except ValueError as e:
        assert "MoviePy couldn't find the codec associated with the filename." \
               " Provide the 'codec' parameter in write_videofile." in str(e)
    close_all_clips(locals())
Пример #20
0
def test_write_gif_ImageMagick_tmpfiles_pix_fmt():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(0.2, 0.5)
    location = os.path.join(TMP_DIR, "imagemagick_tmpfiles_gif.gif")
    clip.write_gif(location,
                   program="ImageMagick",
                   tempfiles=True,
                   pix_fmt="SGI")
    assert os.path.isfile(location)
    close_all_clips(locals())
Пример #21
0
def test_check_codec():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm")
    location = os.path.join(TMP_DIR, "not_a_video.mas")
    try:
        clip.write_videofile(location)
    except ValueError as e:
        assert "MoviePy couldn't find the codec associated with the filename." \
               " Provide the 'codec' parameter in write_videofile." in str(e)
    close_all_clips(locals())
Пример #22
0
def test_errors_with_redirected_logs():
    """Checks error cases return helpful messages even when logs redirected
    See https://github.com/Zulko/moviepy/issues/877"""
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm")
    location = os.path.join(TMP_DIR, "logged-write.mp4")
    with pytest.raises(IOError) as e:
        clip.write_videofile(location, codec="nonexistent-codec", write_logfile=True)
    assert "Unknown encoder 'nonexistent-codec'" in str(e.value)
    close_all_clips(locals())
Пример #23
0
def test_setaudio():
    clip = ColorClip(size=(100, 60), color=(255, 0, 0), duration=0.5)
    make_frame_440 = lambda t: [sin(440 * 2 * pi * t)]
    audio = AudioClip(make_frame_440, duration=0.5)
    audio.fps = 44100
    clip = clip.set_audio(audio)
    location = os.path.join(TMP_DIR, "setaudio.mp4")
    clip.write_videofile(location, fps=24)
    assert os.path.isfile(location)
    close_all_clips(locals())
Пример #24
0
def test_write_frame_errors():
    """Checks error cases return helpful messages"""
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm")
    location = os.path.join(TMP_DIR, "unlogged-write.mp4")
    with pytest.raises(IOError) as e:
        clip.write_videofile(location, codec="nonexistent-codec")
    assert (
        "The video export failed because FFMPEG didn't find the specified codec for video "
        "encoding nonexistent-codec" in str(e.value)), e.value
    close_all_clips(locals())
Пример #25
0
def test_duration():
    clip = TextClip("hello world", size=(1280, 720), color="white", font=FONT)
    clip = clip.set_duration(5)
    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())
Пример #26
0
def test_write_gif_ffmpeg_tmpfiles_pixel_format():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(
        0.2, 0.24)
    location = os.path.join(TMP_DIR, "ffmpeg_tmpfiles_gif.gif")
    clip.write_gif(location,
                   program="ffmpeg",
                   tempfiles=True,
                   pixel_format="bgr24")
    assert os.path.isfile(location)
    close_all_clips(locals())
Пример #27
0
def test_clips_array():
    red = ColorClip((1024, 800), color=(255, 0, 0))
    green = ColorClip((1024, 800), color=(0, 255, 0))
    blue = ColorClip((1024, 800), color=(0, 0, 255))

    video = clips_array([[red, green, blue]])

    with pytest.raises(ValueError):  # duration not set
        video.resize(width=480).write_videofile(join(TMP_DIR, "test_clips_array.mp4"))
    close_all_clips(locals())
Пример #28
0
def test_setaudio():
    clip = ColorClip(size=(100, 60), color=(255, 0, 0), duration=0.5)
    make_frame_440 = lambda t: [sin(440 * 2 * pi * t)]
    audio = AudioClip(make_frame_440, duration=0.5)
    audio.fps = 44100
    clip = clip.set_audio(audio)
    location = os.path.join(TMP_DIR, "setaudio.mp4")
    clip.write_videofile(location, fps=24)
    assert os.path.isfile(location)
    close_all_clips(locals())
Пример #29
0
def test_margin():
    clip = get_test_video()
    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"))
    close_all_clips(locals())
Пример #30
0
def test_setfps_withchangeduration():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(0, 1)
    # The sum is unique for each frame, so we can use it as a frame-ID
    # to check which frames are being preserved
    clip_sums = [f.sum() for f in clip.iter_frames()]

    clip2 = clip.with_fps(48, change_duration=True)
    clip2_sums = [f.sum() for f in clip2.iter_frames()]
    assert clip2_sums == clip_sums
    assert clip2.duration == clip.duration / 2
    close_all_clips(locals())
Пример #31
0
def test_margin():
    clip = get_test_video()
    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"))
    close_all_clips(locals())
Пример #32
0
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())
Пример #33
0
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())
Пример #34
0
def test_concatenate_audiofileclips():
    clip1 = AudioFileClip("media/crunching.mp3").subclip(1, 4)

    # Checks it works with videos as well
    clip2 = AudioFileClip("media/big_buck_bunny_432_433.webm")
    concat_clip = concatenate_audioclips((clip1, clip2))

    concat_clip.write_audiofile(os.path.join(TMP_DIR, "concat_audio_file.mp3"))

    assert concat_clip.duration == clip1.duration + clip2.duration

    close_all_clips(locals())
Пример #35
0
def test_write_frame_errors_with_redirected_logs():
    """Checks error cases return helpful messages even when logs redirected
    See https://github.com/Zulko/moviepy/issues/877"""
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm")
    location = os.path.join(TMP_DIR, "logged-write.mp4")
    with pytest.raises(IOError) as e:
        clip.write_videofile(location, codec="nonexistent-codec", write_logfile=True)
    assert (
        "The video export failed because FFMPEG didn't find the specified codec for video "
        "encoding nonexistent-codec" in str(e.value)
    )
    close_all_clips(locals())
Пример #36
0
def test_loop():
    clip = get_test_video()
    clip1 = loop(clip).set_duration(3)  # infinite looping
    clip1.write_videofile(os.path.join(TMP_DIR, "loop1.webm"))

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

    clip3 = loop(clip, n=3)  # loop 3 times
    clip3.write_videofile(os.path.join(TMP_DIR, "loop3.webm"))
    close_all_clips(objects=locals())
Пример #37
0
def test_clips_array():
    red = ColorClip((1024, 800), color=(255, 0, 0))
    green = ColorClip((1024, 800), color=(0, 255, 0))
    blue = ColorClip((1024, 800), color=(0, 0, 255))

    video = clips_array([[red, green, blue]])

    with pytest.raises(ValueError,
                       message="Expecting ValueError (duration not set)"):
        video.resize(width=480).write_videofile(
            join(TMP_DIR, "test_clips_array.mp4"))
    close_all_clips(locals())
Пример #38
0
def test_clips_array():
    red = ColorClip((1024, 800), color=(255, 0, 0))
    green = ColorClip((1024, 800), color=(0, 255, 0))
    blue = ColorClip((1024, 800), color=(0, 0, 255))

    video = clips_array([[red, green, blue]])

    with pytest.raises(ValueError) as exc_info:
        video.resize(width=480).write_videofile(join(TMP_DIR, "test_clips_array.mp4"))
    assert str(exc_info.value) == "Attribute 'duration' not set"

    close_all_clips(locals())
Пример #39
0
def test_audioclip():
    make_frame = lambda t: [sin(440 * 2 * pi * t)]
    audio = AudioClip(make_frame, duration=2, fps=22050)
    audio.write_audiofile(os.path.join(TMP_DIR, "audioclip.mp3"), bitrate="16")

    assert os.path.exists(os.path.join(TMP_DIR, "audioclip.mp3"))

    clip = AudioFileClip(os.path.join(TMP_DIR, "audioclip.mp3"))

    # TODO Write better tests; find out why the following fail
    # assert clip.duration == 2
    # assert clip.fps == 22050
    # assert clip.reader.bitrate == 16
    close_all_clips(locals())
Пример #40
0
def test_loop():
    # these do not work..  what am I doing wrong??
    return

    clip = get_test_video()
    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"))
    close_all_clips(objects=locals())
Пример #41
0
def test_concatenate_floating_point():
    """
    >>> print("{0:.20f}".format(1.12))
    1.12000000000000010658

    This test uses duration=1.12 to check that it still works when the clip duration is
    represented as being bigger than it actually is. Fixed in #1195.
    """
    clip = ColorClip([100, 50], color=[255, 128, 64],
                     duration=1.12).with_fps(25.0)
    concat = concatenate_videoclips([clip])
    concat.write_videofile(os.path.join(TMP_DIR, "concat.mp4"),
                           preset="ultrafast")
    close_all_clips(locals())
Пример #42
0
def test_loop():
    # these do not work..  what am I doing wrong??
    return

    clip = get_test_video()
    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"))
    close_all_clips(objects=locals())
Пример #43
0
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())
Пример #44
0
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())
Пример #45
0
def test_write_videofiles_with_temp_audiofile_path():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(0.2, 0.5)
    location = os.path.join(TMP_DIR, "temp_audiofile_path.webm")
    temp_location = os.path.join(TMP_DIR, "temp_audiofile")
    if not os.path.exists(temp_location):
        os.mkdir(temp_location)
    clip.write_videofile(location,
                         temp_audiofile_path=temp_location,
                         remove_temp=False)
    assert os.path.isfile(location)
    contents_of_temp_dir = os.listdir(temp_location)
    assert any(
        file.startswith("temp_audiofile_path")
        for file in contents_of_temp_dir)
    close_all_clips(locals())
Пример #46
0
def test_clips_array_duration():
    # NOTE: anyone knows what behaviour this sets ? If yes please replace
    # this comment.
    red = ColorClip((256, 200), color=(255, 0, 0))
    green = ColorClip((256, 200), color=(0, 255, 0))
    blue = ColorClip((256, 200), color=(0, 0, 255))

    video = clips_array([[red, green, blue]]).with_duration(5)
    with pytest.raises(AttributeError):  # fps not set
        video.write_videofile(join(TMP_DIR, "test_clips_array.mp4"))

    # this one should work correctly
    red.fps = green.fps = blue.fps = 30
    video = clips_array([[red, green, blue]]).with_duration(5)
    video.write_videofile(join(TMP_DIR, "test_clips_array.mp4"))
    close_all_clips(locals())
Пример #47
0
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())
Пример #48
0
def test_clips_array_duration():
    # NOTE: anyone knows what behaviour this sets ? If yes please replace
    # this comment.
    red = ColorClip((256, 200), color=(255, 0, 0))
    green = ColorClip((256, 200), color=(0, 255, 0))
    blue = ColorClip((256, 200), color=(0, 0, 255))

    video = clips_array([[red, green, blue]]).set_duration(5)
    with pytest.raises(AttributeError,
                       message="Expecting ValueError (fps not set)"):
        video.write_videofile(join(TMP_DIR, "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(join(TMP_DIR, "test_clips_array.mp4"))
    close_all_clips(locals())
Пример #49
0
def test_rotate():
    clip = get_test_video()

    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"))
    close_all_clips(locals())
Пример #50
0
def test_crop():
    clip = get_test_video()

    clip1 = crop(clip)  # ie, no cropping (just tests all default values)
    clip1.write_videofile(os.path.join(TMP_DIR, "crop1.webm"))

    clip2 = crop(clip, x1=50, y1=60, x2=460, y2=275)
    clip2.write_videofile(os.path.join(TMP_DIR, "crop2.webm"))

    clip3 = crop(clip, y1=30)  # remove part above y=30
    clip3.write_videofile(os.path.join(TMP_DIR, "crop3.webm"))

    clip4 = crop(clip, x1=10, width=200)  # crop a rect that has width=200
    clip4.write_videofile(os.path.join(TMP_DIR, "crop4.webm"))

    clip5 = crop(clip, x_center=300, y_center=400, width=50, height=150)
    clip5.write_videofile(os.path.join(TMP_DIR, "crop5.webm"))

    clip6 = crop(clip, x_center=300, width=400, y1=100, y2=600)
    clip6.write_videofile(os.path.join(TMP_DIR, "crop6.webm"))
    close_all_clips(locals())
Пример #51
0
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())
Пример #52
0
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())
Пример #53
0
def test_write_gif_ImageMagick_tmpfiles():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(0.2, 0.5)
    location = os.path.join(TMP_DIR, "imagemagick_tmpfiles_gif.gif")
    clip.write_gif(location, program="ImageMagick", tempfiles=True)
    assert os.path.isfile(location)
    close_all_clips(locals())
Пример #54
0
def test_cuts1():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").resize(0.2)
    cuts.find_video_period(clip) == pytest.approx(0.966666666667, 0.0001)
    close_all_clips(locals())
Пример #55
0
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())
Пример #56
0
def test_fadeout():
    clip = get_test_video()
    clip1 = fadeout(clip, 0.5)
    clip1.write_videofile(os.path.join(TMP_DIR, "fadeout1.webm"))
    close_all_clips(locals())
Пример #57
0
def test_withoutaudio():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").subclip(0.2, 0.6)
    new_clip = clip.without_audio()
    assert new_clip.audio is None
    close_all_clips(locals())
Пример #58
0
def test_normalize():
    clip = AudioFileClip('media/crunching.mp3')
    clip = audio_normalize(clip)
    assert clip.max_volume() == 1
    close_all_clips(locals())
Пример #59
0
def test_blackwhite():
    clip = get_test_video()
    clip1 = blackwhite(clip)
    clip1.write_videofile(os.path.join(TMP_DIR, "blackwhite1.webm"))
    close_all_clips(locals())
Пример #60
0
def test_colorx():
    clip = get_test_video()
    clip1 = colorx(clip, 2)
    clip1.write_videofile(os.path.join(TMP_DIR, "colorx1.webm"))
    close_all_clips(locals())