如何组合剪辑而不弄乱奥迪

2024-09-29 23:28:16 发布

您现在位置:Python中文网/ 问答频道 /正文

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

我增加了fps,这只是增加了它被满足的时间

视频创作者

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\u中的prefexe\u,标题为: 如果标题索引的prefexes\u(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')

Tags: ofthetextimageforclip音频audio

热门问题