1

I am new to Python. Now I have 1.mp3 file and 1.mp4 file.

The mp3 file is short and lasts 1s. The path of mp3 is C:/1.mp3 The mp4 file is longer and lasts 20s. The path of mp4 is C:/1.mp4

I want to insert the 1.mp3 to the 1.mp4 at 5s and 10s

How can I do it? Thank you all in advance

1 Answers1

1
from moviepy.editor import *

clip = VideoFileClip("1.mp4")
audio = AudioFileClip("1.mp3")
clip.audio = CompositeAudioClip([audio, clip.subclip(1, 5).audio.set_start(1), audio.set_start(5), clip.subclip(6, clip.duration).audio.set_start(6)])
clip.write_videofile('final_video.mp4', codec="libx264", audio_codec="aac")