I figured out how I can concatenate multiple audio files with complex filter, but struggling with offsetting audio in result file. Say, I want to add a gap of 1 seconds silence between each concatenate file. Is it possible to do with FFmpeg?
Asked
Active
Viewed 3,547 times
1 Answers
11
Generate a null audio stream and insert that with a trim.
Let's say you have three audio files and you want gaps of 1 and 3 seconds between them respectively, then you would use
ffmpeg -i 1.mp3 -i 2.mp3 -i 3.mp3 -f lavfi -i anullsrc -filter_complex \
"[3]atrim=duration=1[g1];[3]atrim=duration=3[g2];
[0][g1][1][g2][2]concat=n=5:v=0:a=1" out.mp3
If you need to trim the inputs as well,
ffmpeg -i 1.mp3 -i 2.mp3 -i 3.mp3 -f lavfi -i anullsrc -filter_complex \
"[0]atrim=duration=20[t0];[1]atrim=duration=120[t1];[2]atrim=duration=45[t2];
[3]atrim=duration=1[g1];[3]atrim=duration=3[g2];
[t0][g1][t1][g2][t2]concat=n=5:v=0:a=1" out.mp3
Gyan
- 34,439
- 6
- 56
- 98
-
What if i want to ceil duration of inputs before concat and trim? – layabout Sep 02 '16 at 07:37
-
See new command. – Gyan Sep 02 '16 at 08:03
-
Thank you for help! Could you please point me where can i read about input labels? I am not quite understand the meaning of all values in brackets. Also why n=5? 3 input files and anullsrc but from where 5th came? – layabout Sep 02 '16 at 08:20
-
See https://ffmpeg.org/ffmpeg-filters.html#Filtergraph-syntax-1 – Gyan Sep 02 '16 at 08:26
-
15 refers to total number of input pads. The anullsrc is fed twice. – Gyan Sep 02 '16 at 08:27