0

suppose that I have a audio file(10s), and I also have another one(2s). What I want is to overlay the second one to the first one, for example: first file(10s): 1111111111 (where "1" stands for 1sec), Second file(2s): 22. If I want to overlay the second file on first file on time-line 5s,6s: 1111221111. How should i do? I have already search for some solution like: ffmpeg, but i want this can be done without using server. Thanks.

Huang Liang-Syun
  • 129
  • 1
  • 3
  • 10

1 Answers1

1

amix filter is what you are looking for. It will mix/overlay the audios according to your need. Simply you can append a 4 sec silent audio using aevalsrc to the second audio and mix the result with first audio.

ffmpeg -i input_audio1 -i input_audio2 -filter_complex "
aevalsrc=0:d=4[s1];
[s1][1:a]concat=n=2:a=1:v=0[a2];
[0:a][a2]amix" -c:a libmp3lame output_audio

You can use appropriate audio codec according to you output audio format. Here I have used libmp3lame for a mp3 and you can find all the codecs here. Also if you need to trim the audio to a specific length, you can use atrim with filter_complex or -t option accordingly.

Hope this helps!

Chamath
  • 2,016
  • 2
  • 21
  • 30
  • is it possible to add the silence using milliseconds instead of seconds? According to the documentation it looks it's not possible? Do you have a way to do it? Basically something like aevalsrc=0:d=0,5[s1];(e.g. half second) – Nadir Dec 31 '16 at 18:50