Concatenate and loop MP3 files

1

I want to concatenate and loop 3 MP3 files.

grammaraudio1.mp3 grammaraudio2.mp3 grammarsudio3.mp3 

The output file must loop the first MP3 file five times, then the second one 5 times, etc. Can I use ffmpeg to do this?

I'd like the second part of the track to include the same MP3 files, but looped only 3 times. Then a third part that can loop each file just once or twice. The command must output a single MP3 file.

Example output, where x# is the number of times looped:

GA1.mp3 (x5) GA2.mp3 (x5) GA3.mp3 (x5) GA1.mp3 (x3) GA2.mp3 (x3) GA3.mp3 (x3) GA1.mp3 (x2) GA2.mp3 (x2) GA3.mp3 (x2)

Jake Mackenzie

Posted 2018-07-06T23:52:16.463

Reputation: 13

Answers

2

Assuming the MP3s have the same sampling rate and channel count, use

ffmpeg -f lavfi -i amovie=grammaraudio1.mp3:loop=5,asetpts=N/SR/TB
       -f lavfi -i amovie=grammaraudio2.mp3:loop=5,asetpts=N/SR/TB
       -f lavfi -i amovie=grammaraudio3.mp3:loop=5,asetpts=N/SR/TB
       -f lavfi -i amovie=grammaraudio1.mp3:loop=3,asetpts=N/SR/TB
       -f lavfi -i amovie=grammaraudio2.mp3:loop=3,asetpts=N/SR/TB
       -f lavfi -i amovie=grammaraudio3.mp3:loop=3,asetpts=N/SR/TB
       -f lavfi -i amovie=grammaraudio1.mp3:loop=2,asetpts=N/SR/TB
       -f lavfi -i amovie=grammaraudio2.mp3:loop=2,asetpts=N/SR/TB
       -f lavfi -i amovie=grammaraudio3.mp3:loop=2,asetpts=N/SR/TB
       -filter_complex "[0][1][2][3][4][5][6][7][8]concat=n=9:v=0:a=1" out.mp3

Single command, no intermediate files.

Gyan

Posted 2018-07-06T23:52:16.463

Reputation: 21 016

I appreciate that Gyan. Is there any way to use a wildcard to concatenate the whole contents of a folder, regardless of name? You could assign names to each file and then concatenate them using those names. I'll research it. – Jake Mackenzie – 2018-07-08T05:28:21.277