1
votes

Good Day,

I would like to know if it is possible to "join" a portion of an mp3 file to another without re-encoding using ffmpeg. I need to prepend an audio mp3 file with silence to ensure it is 60 seconds long.

i.e if my audio file a.mp3 is 40 seconds I need to prepend 20 seconds of silence without re-encoding.

My thoughts on doing this was to have a 60 second long silence mp3 (silence.mp3) at the same CBR and sample rate of my audio (44100 and 40kbps). I then need to "trim" this file and concat/join with the audio file (a.mp3) appropriately.

I have a linux script that computes the required seconds to prepend and I tried using the following filter_complex expression:

ffmpeg -i silence.mp3 -i a.mp3 -filter_complex "[1]adelay=20000[b];[0][b]amix=2" out.mp3

This works however takes too long as it performs re-encoding which takes a long to process. Im looking for a non re encoding solution that can just join the correct sized portion of silence.mp3 to a.mp3. The commands would need to include as a parameter the length of silence that must be used from the overall silence.mp3 file.

Any advise is appreciated.

1

1 Answers

1
votes

Your requirement is to not re-encode and yet that's what your method does.

Let's say you have a silent MP3 of the required duration ready.

Create a text file, list.txt

file silence.mp3
outpoint 20
file main.mp3

and join

ffmpeg -f concat -i list.txt -c copy merged.mp3

I assume the properties of silence.mp3 match the main audio file, in terms of channel count and sampling rate.