如何在不使音频混乱的情况下组合片段

时间:2019-07-15 18:59:29

标签: python moviepy

我正在编写一个程序,将文本转换为语音音频,将其与由图像制成的视频相结合,然后合并多个文件。当它这样做时,音频变得混乱并且在剪辑之间交错,我将如何进行音频或剪辑组合以防止这种情况

我提高了fps,这只是增加了它的处理时间

vid创作者

for prefexe in prefexes_for_title:
    #we first need to find the length of the audio 
    audio = MP3(prefexe+'.mp3')
    leng = audio.info.length
    #we should round that so the fps will come out nicly 
    leng = round(leng+.5)
    fpsq = 1 #fps
    image_of_text = Image.open(prefexe+'.png')
    image_of_text = numpy.array(image_of_text)#convert to np array
    frame_list = []#were we will put all the frames 
    for sec in range(leng):#iterates throught all the frames 
        frame_list.append(image_of_text)
    clip = mpe.ImageSequenceClip(frame_list, fps=fpsq)#creates a vid out of the frames
    clip.write_videofile(prefexe+'.mp4')
    #time to combind this file with the audio ;(I)
    clip_for_audio = mpe.VideoFileClip(prefexe+'.mp4')
    audioclip = mpe.AudioFileClip(prefexe+'.mp3')
    videoclip2 = clip_for_audio.set_audio(audioclip)

    videoclip2.write_videofile(prefexe+'.mp4')

组合器

prefexes_for_title中的prefexe:         如果prefexes_for_title.index(prefexe)== 0:             clip1 = mpe.VideoFileClip(prefexe +'.mp4')

    else:
        clip2 = mpe.VideoFileClip(prefexe + '.mp4')
        final_clip1 = mpe.concatenate_videoclips([clip1,clip2])
        final_clip1.write_videofile('a0.mp4')
        clip1 = mpe.VideoFileClip('a0.mp4')

0 个答案:

没有答案