Пример #1
0
def test_find_video_period():
    clip = VideoFileClip("media/chaplin.mp4").subclip(0, 0.5).loop(2)  # fps=25

    # you need to increase the fps to get correct results
    assert round(find_video_period(clip, fps=70), 6) == 0.5
from moviepy.editor import VideoFileClip
import moviepy.video.tools.cuts as cuts
import moviepy.editor as mpy

clip = mpy.VideoFileClip("bunny.mp4").resize(0.2).subclip((4,32),(4,33))
# error, can
t_loop = cuts.find_video_period(clip) # gives t=0.56
clip.subclip(0,t_loop).write_gif('gifs/example10.gif')
  * moviepy (pip install moviepy)
    * decorator
    * imageio
    * olefile
    * pillow
    * tqdm
  * gizeh (VC++ 14.0: http://landinghub.visualstudio.com/visual-cpp-build-tools)
    * cairocffi
    * cffi
    * pycparser
    
  Problems:
  * OSError: dlopen() failed to load a library: cairo / cairo-2 => 下载GTK+,并
    将bin目录加入环境变量(http://win32builder.gnome.org/)
  
"""

import moviepy.editor as mpy
import moviepy.video.tools.cuts as cuts

src_video = "./resources/test.mp4"
outputdir = "./output/"
start_time = (10, 4)
end_time = (10, 14)

clip = mpy.VideoFileClip(src_video).resize(0.3).subclip(start_time, end_time)
# change cuts length by changing parameter "tmin" to 10:14 - 10.4 - 0.1
t_loop = cuts.find_video_period(clip, tmin = 9.9)
clip.subclip(0, t_loop).write_gif(outputdir + "movie_clip_animation.gif",
                                  opt = "OptimizePlus")
Пример #4
0
         .subclip((4,7), (4,18))
         .audio_fadein(1)
         .audio_fadeout(1))

audio_period = find_audio_period(audio)
print ('Analyzed the audio, found a period of %.02f seconds'%audio_period)


# LOAD, EDIT, ANALYZE THE VIDEO


clip = (VideoFileClip("./knights.mp4", audio=False)
        .subclip((1,24.15),(1,26))
        .crop(x1=332, x2=910, y2=686))

video_period = find_video_period(clip, tmin=.3)
print ('Analyzed the video, found a period of %.02f seconds'%video_period)

edited_right = (clip.subclip(0,video_period)
                .speedx(final_duration=2*audio_period)
                .fx(vfx.loop, duration=audio.duration)
                .subclip(.25))

edited_left = edited_right.fx(vfx.mirror_x)

dancing_knights = (clips_array([[edited_left, edited_right]])
                   .fadein(1).fadeout(1).set_audio(audio).subclip(.3))

# MAKE THE TITLE SCREEN

Пример #5
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)
Пример #6
0
from moviepy.editor import VideoFileClip
import moviepy.video.tools.cuts as cuts
import moviepy.editor as mpy

clip = mpy.VideoFileClip("bunny.mp4").resize(0.2).subclip((4, 32), (4, 33))
# error, can
t_loop = cuts.find_video_period(clip)  # gives t=0.56
clip.subclip(0, t_loop).write_gif('gifs/example10.gif')
Пример #7
0
#==========

# LOAD, EDIT, ANALYZE THE AUDIO

audio = (AudioFileClip("frontier.mp4").subclip(
    (4, 7), (4, 18)).audio_fadein(1).audio_fadeout(1))

audio_period = find_audio_period(audio)
print('Analyzed the audio, found a period of %.02f seconds' % audio_period)

# LOAD, EDIT, ANALYZE THE VIDEO

clip = (VideoFileClip("./knights.mp4", audio=False).subclip(
    (1, 24.15), (1, 26)).crop(x1=332, x2=910, y2=686))

video_period = find_video_period(clip, tmin=.3)
print('Analyzed the video, found a period of %.02f seconds' % video_period)

edited_right = (clip.subclip(0, video_period).speedx(
    final_duration=2 * audio_period).fx(vfx.loop,
                                        duration=audio.duration).subclip(.25))

edited_left = edited_right.fx(vfx.mirror_x)

dancing_knights = (clips_array(
    [[edited_left,
      edited_right]]).fadein(1).fadeout(1).set_audio(audio).subclip(.3))

# MAKE THE TITLE SCREEN

txt_title = (TextClip("15th century dancing\n(hypothetical)",
Пример #8
0
def test_cuts1():
    clip = VideoFileClip("media/big_buck_bunny_432_433.webm").fx(resize, 0.2)
    find_video_period(clip) == pytest.approx(0.966666666667, 0.0001)
    close_all_clips(locals())
Пример #9
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)