0

I want to mix multiple audio files and export single audio file, to demonstrate, here's a example timeline;

audio1 : -----------------------------------------------------------------------

audio2 :      ===============

audio3 :                                   +++++++++++

audio4 :                                                         ************

audio5 :                                                     ~~~~~~~~~

I have the delay times, like, audio2 should be played with 2 seconds delay after audio1 is played and etc. How can I mix these AudioFileClip()?

soroushamdg
  • 191
  • 1
  • 2
  • 14

1 Answers1

1

Use CompositeAudioClip with clip.set_start().

In a single line, you could do mixed = CompositeAudioClip([audio1, audio2.set_start(2), audio3.set_start(7)]). If you have complicated start times or other effects that you wish to apply, you can of course break it out into more lines.

Tom Burrows
  • 2,225
  • 2
  • 29
  • 46
  • Thanks. I guess it should work ok, but when I try to export the CompositeAudioClip with write_audiofile() function, it gives "'CompositeAudioClip' object has no attribute 'fps'" error. What should I do? – soroushamdg Oct 14 '20 at 19:54
  • I defined CompositeAudioClip fps by audio1 file fps and fixed it : mixed.fps = audio1.fps – soroushamdg Oct 14 '20 at 20:19
  • Yeah that works. CompositeVideoClip automatically sets its FPS based on its input videos so I’m surprised that CompositeAudioClip doesn’t. Feel free to make an issue on GitHub to ask for it :) – Tom Burrows Oct 14 '20 at 21:43