Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg - how to merge multiple audio with time offset into a video? [closed]

Tags:

ffmpeg

I want to use FFMPEG to merege multiple audios and one video.

Materials are:

  1. two short audio clips (short-clip-1.3gp, short-clip-2.3gp),
  2. one video clip (1.mp4) with sound,
  3. and one audio clip (1.mp3) that has same duration as the video clip.

Requirement is:

  1. Remove video clip's sound
  2. add 1.mp3
  3. add short-clip-1.3gp at 0 sec timetamp, short-clip-2.3gp at 10 sec timestamp.

The requirement is depicted like below.

<--short-clip-1.3gp time duration--> <--short-clip-2.3gp time duration-->

<-------------------------------------- 1.mp3 ----------------------------------------------------->

<-------------------------------------- 1.mp4 ----------------------------------------------------->

The command I use is as below, but it does not work as expected. ffmpeg -i 1.mp4 -i 1.3gp -itsoffset 00:00:10 -i 2.3gp -i 1.mp3 -map 0:v -map 1:a -map 2:a -map 3:a -c:v copy -c:a copy result.mp4

Any hint is appreciated!

like image 827
Xi Xiao Avatar asked May 28 '17 20:05

Xi Xiao


1 Answers

Thanks to Mulvya's solution. Here are extra info for how to mix multiple audio stream with delay requirement:

ffmpeg -i 1.mp3 -i 1.3gp -i 2.3gp -i 3.3gp -i 4.3gp -i 5.3gp -i 1.mp4 \ 
-filter_complex "[2]adelay=2790|2790[s2];\
[3]adelay=10300|10300[s3];\
[4]adelay=14930|14930[s4];\
[5]adelay=21090[s5];\
[0][1][s2][s3][s4][s5]amix=6[mixout]" \
-map 6:v -map [mixout] -c:v copy result.mp4

The difficult part is: [2]adelay=2790|2790[s2] . it means 'select 3rd input, give 2,79sec delay and ouput as s2', the 's2' is used in following 'amix' command to generate a '6[mixout]' which is used then in '-map'.

like image 79
Xi Xiao Avatar answered Sep 28 '22 13:09

Xi Xiao