0

I am trying to edit videos from moviepy and from moviepy I want to add 4 different audio files. I didn't find any documentation. I guess. Is this possible?

I tried a lot but can't figure it out.

from moviepy.editor import *
audio1=AudioFileClip("audio1.mp3")
audio2=AudioFileClip("audio2.mp3")
audio3=AudioFileClip("audio3.mp3")
audio4=AudioFileClip("audio4.mp3")

#I want to mix all these audio and add it in a video

video=VideoFileClip("video.mp4")

#now add that mixed audio and export it.
#what should I do here to mix all the audio and assign them to a variable.

finalvideo.writevideofile("finalvideo.mp4")
  
halfer
  • 19,824
  • 17
  • 99
  • 186
  • You can use `combined = CompositeAudioClip([audio1,audio2,audio3,audio4,video.audio])` and then `finalvideo =video.set_audio(combined)` – Tom Burrows Aug 15 '20 at 20:57
  • Is that possible? – Dipesh Khanal Aug 16 '20 at 07:14
  • Thanks, It worked. I also have another doubt. just like while exporting we give it directory to export the video. can we set a variable and add that variable in directory. ``` directory= somename``` and ``` finalvideo.write_videofiles("directory\videoname.mp4")``` Can we do that – Dipesh Khanal Aug 16 '20 at 07:28
  • Give it a try :) Yes that will almost work (but it is `write_videofile` not `write_videofiles`). If `directory` is a string, then do `finalvideo.write_videofile(directory + "\\videoname.mp4")` – Tom Burrows Aug 16 '20 at 11:05
  • yeah I tried it and I worked thanks mate – Dipesh Khanal Aug 16 '20 at 17:02

0 Answers0