2

I have a series of mp3 files with a start time offset.

I am trying to merge them together with adelay and amix.

The following codes run and creates the combined MP3 but when I listen to the final output file there are spots where people are talking over each other not in the sense they are being rude but the audio being out of sync.

Here are the files with the start and stoptime offsets:

d4a19a58-790a-45c1-b96e-819bc98cd408.webm | 1720 | 3762173
ab794f92-bdfb-4bb0-821d-ba80c8a9228a.webm | 48920 | 3328385
a7df9a51-0671-4930-a14b-e7d85a562577.webm | 76220 | 3763361
5d312878-d25d-40d7-9418-bed85e22efc6.webm | 3109640 | 3267473
1cf6127d-250a-4601-a219-b1b6bbd725f8.webm | 3360980 | 3636927
c3ddd462-e05a-425f-af58-f288f930f2cb.webm | 3689600 | 3760423

Here is the command I used to get the webm file to convert to MP3 broken into lines for readability:

ffmpeg 
-acodec libopus 
-i d4a19a58-790a-45c1-b96e-819bc98cd408.webm 
-b:a 320K 
-vn 
-y d4a19a58-790a-45c1-b96e-819bc98cd408.mp3

Here is the command broke to combine all the mp3s into lines for easier readability:

ffmpeg 
-i d4a19a58-790a-45c1-b96e-819bc98cd408.mp3 
-i ab794f92-bdfb-4bb0-821d-ba80c8a9228a.mp3 
-i a7df9a51-0671-4930-a14b-e7d85a562577.mp3 
-i 1cf6127d-250a-4601-a219-b1b6bbd725f8.mp3 
-i c3ddd462-e05a-425f-af58-f288f930f2cb.mp3 
-filter_complex "
[0]adelay=1720|1720[a0];
[1]adelay=48920|48920[a1];
[2]adelay=76220|76220[a2];
[3]adelay=3360980|3360980[a3];
[4]adelay=3689600|3689600[a4];
[a0][a1][a2][a3][a4]amix=inputs=5
" 
out.mp3 -y

Any ideas on what I am doing wrong?

6
  • How did you convert the mp3s from the webm?
    – Gyan
    Commented Jan 23, 2021 at 4:55
  • @Gyan, I updated the post to show the command to convert webm to mp3 Commented Jan 23, 2021 at 15:30
  • Is the duration of the webm and MP3 the same?
    – Gyan
    Commented Jan 23, 2021 at 16:34
  • @Gyan, good question, I confirmed they are the same. Commented Jan 23, 2021 at 23:06
  • Very hard if not impossible to answer without input files and exact ffmpeg version information.
    – user564335
    Commented Jan 31, 2021 at 12:05

1 Answer 1

1

you need to delay all the audio channels with the same value using adelay=milliseconds:all=true, and use -async 1 at the end of your command so ffmpeg will just corrects the start of the audio stream instead of stretching/squeezing.

so in your case :

ffmpeg 
-i input1.webm 
-i input2.webm
-i input3.webm
-i input4.webm
-i input5.webm
-filter_complex "
[0]adelay=1720:all=true[a0];
[1]adelay=48920:all=true[a1];
[2]adelay=76220:all=true[a2];
[3]adelay=3360980:all=true[a3];
[4]adelay=3689600:all=true[a4];
[a0][a1][a2][a3][a4]amix=inputs=5 [out]
"
-map "[out]"
out.webm -async 1 -y

as the documentations says :

-async samples_per_second

Audio sync method. "Stretches/squeezes" the audio stream to match the timestamps, the parameter is the maximum samples per second by which the audio is changed. -async 1 is a special case where only the start of the audio stream is corrected without any later correction.

1
  • note that the doc says -async option is deprecated and you should use aresample=async=1 in the filter instead but -async 1 is working for now
    – ben
    Commented Aug 28, 2022 at 13:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .