1

I want to Merge two mp3 files with a silence in between two mp3 files. I can now merge Songs with my code, but i need to add silence of 'x' seconds between songs. and the 'x' needed to be a value user can change.. So the only thing i needed is a code to Create a silence mp3 file that have a duration of 'x' seconds ...

Lins Louis
  • 1,838
  • 1
  • 24
  • 28
  • See answer for Java here: http://stackoverflow.com/questions/31800815/programmatically-create-mp3 – hilzj May 17 '16 at 11:21

2 Answers2

4

You can use the FFmpeg anullsrc source filter:

ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -t 5 out.mp3

The -t option defines the duration. This example will make a 5 second output.

llogan
  • 105,293
  • 25
  • 200
  • 219
2

To merge in between, basic syntax is

ffmpeg -i first.mp3 -i second.mp3 -f lavfi -i aevalsrc=0:d=x \
-filter_complex "[0][2][1]concat=n=3:v=0:a=1" merged.mp3

where x should be replaced with the duration of the silence (in seconds).

Gyan
  • 74,575
  • 7
  • 138
  • 171