'Python: how can I Insert mp3 to one Mp4 Video at specific time
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
Solution 1:[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")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
