Thomas
Thomas

Reputation: 43

ffmpeg: How to repeat an audio "watermark"

I have a question concerning FFMpeg. I would like to "inject" a mp3 (beep) file once every e.g. 5 sec into an other mp3 file. Can any of you provide me with some guidance on how to do this.

Many thanks in advance!

Upvotes: 3

Views: 4284

Answers (2)

Ben
Ben

Reputation: 4371

I had some issues with Gyan's answer causing files to encode as just the first second of audio and nothing else.

For me this slightly adjusted filter works:

ffmpeg -y -i input.mp3 -filter_complex "amovie=/home/code/watermark.wav:loop=0,volume=2,asetpts=N/SR/TB[bg];[bg][0]amix=duration=shortest" -threads 12 -acodec libmp3lame -b:a 128k outtest.mp3

Upvotes: 1

Gyan
Gyan

Reputation: 93319

#1 Process the beep to make it 5 seconds long:

ffmpeg -i beep.mp3 -af apad -t 5 beep.wav

#2 Mix with the other audio

ffmpeg -i main.mp3 -filter_complex "amovie=beep.wav:loop=0,asetpts=N/SR/TB[beep];
                                    [0][beep]amix=duration=shortest,volume=2"   out.mp3

loop=0 makes the input loop indefinitely. The asetpts is to make the timestamps of the loop continuous.

Upvotes: 4

Related Questions