我正在尝试使用MoviePy将音频与视频合并。 音频的持续时间长于视频,因此我将其更改为视频的持续时间。
这是我的代码:
from moviepy.editor import AudioFileClip, VideoFileClip
video = 'youtube.mp4'
audio = 'voice.mp3'
nName = 'youtube2.mp4'
vClip = VideoFileClip(video)
aClip = AudioFileClip(audio)
print(vClip.duration)
print(aClip.duration)
fAudioClip = aClip.subclip(0.000, vClip.duration)
fVideoClip = vClip.set_audio(fAudioClip)
fVideoClip.write_videofile(nName, codec='libx264',audio_codec='aac')
输出-
*424.96
428.92
Moviepy - Building video youtube2.mp4.
MoviePy - Writing audio in youtube2TEMP_MPY_wvf_snd.mp4
MoviePy - Done.
Moviepy - Writing video youtube2.mp4
Moviepy - Done !
Moviepy - video ready youtube2.mp4*
但是,与音频相比,视频的运行速度快得多,并且播放很快。我该怎么做才能解决此问题?