Esempio n. 1
0
def test_find_audio_period(mono_wave, stereo_wave, wave_type):
    if wave_type == "mono":
        wave1 = mono_wave(freq=400)
        wave2 = mono_wave(freq=100)
    else:
        wave1 = stereo_wave(left_freq=400, right_freq=220)
        wave2 = stereo_wave(left_freq=100, right_freq=200)
    clip = CompositeAudioClip([
        AudioClip(make_frame=wave1, duration=0.3, fps=22050),
        multiply_volume(
            AudioClip(make_frame=wave2, duration=0.3, fps=22050),
            0,
            end_time=0.1,
        ),
    ])
    loop_clip = loop(clip, 4)
    assert round(find_audio_period(loop_clip),
                 6) == pytest.approx(0.29932, 0.1)
def generate():
    global clip_duration
    print( "Creating movie of %s seconds. Max segment length: %s." % ( output_file_duration, max_seg_length ) )

    audio = (AudioFileClip("input/Uptown Spot - 1.mp4").audio_fadein(1).audio_fadeout(1))
    audio_period = find_audio_period(audio)
    print ('Analyzed the audio, found a period of %.02f seconds'%audio_period)
    clip_duration = audio_period

    files = getVideoFiles( src_path ) # load all the clips in the /input directory
    final = mainComp( files ) # make random selection add filters and concat them

    audio = audio.set_duration( final.duration )
    final.audio = audio
    final = effectsGenerator( final, 2 ) # add effects to the whole shebang

    timestr = time.strftime( "%Y-%m%d-%H%M%S" )
    filename = "output/hdsa%s.mp4" % timestr
    final.write_videofile( filename, threads = 16 ) # write the video to file
    #final.save_frame( "frame.png", t = 0.5 ) # saves the frame a t=2s

    print ( "\a" )
    print("--- %s seconds ---" % (time.time() - start_time))
Esempio n. 3
0
import os
# if not os.path.exists("knights.mp4"):
#     os.system("youtube-dl zvCvOC2VwDc -o knights.mp4")
#     os.system("youtube-dl lkY3Ek9VPtg -o frontier.mp4")
#==========


# LOAD, EDIT, ANALYZE THE AUDIO


audio = (AudioFileClip("../datasets/lstm_net.avi")
         .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("../datasets/lstm_net.avi", 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)
Esempio n. 4
0
import os
if not os.path.exists("knights.mp4"):
    os.system("youtube-dl zvCvOC2VwDc -o knights.mp4")
    os.system("youtube-dl lkY3Ek9VPtg -o frontier.mp4")
#==========


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