如何在python中合并mp3和mp4/将mp4文件静音并在其上添加mp3文件



如果可能的话,我想在python中合并一个mp3和一个mp4,并使用moviepy库。

但是我的mp4视频中有一些声音,所以我想之前删除这个声音。

我很难找到有效的东西,所以我想很多人也可能有这种困难,所以下面是对我有效的代码:

def combine_audio(vidname, audname, outname, fps=60): 
import moviepy.editor as mpe
my_clip = mpe.VideoFileClip(vidname)
audio_background = mpe.AudioFileClip(audname)
final_clip = my_clip.set_audio(audio_background)
final_clip.write_videofile(outname,fps=fps)
combine_audio("test.mp4", "test.mp3", "test_over.mp4") # i create a new file
combine_audio("test.mp4", "test.mp3", "test.mp4") # i rewrite on the same file```

最新更新