我正在编写一个程序,将文本转换为语音音频,并将其与由图像生成的视频相结合,然后合并多个文件。当它这样做时,音频会被弄乱并在剪辑之间交错,我该如何进行音频或剪辑组合以防止这种情况
我增加了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')
目前没有回答
相关问题 更多 >
编程相关推荐