How to Create A Silent Mp3 File that have a duration of 'x' seconds in android

时间:2016-05-17 11:08:19

标签: java android audio ffmpeg mp3

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 ...

2 个答案:

答案 0 :(得分:2)

您可以使用FFmpeg anullsrc source filter

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

-t选项定义持续时间。这个例子将产生5秒的输出。

答案 1 :(得分:2)

要在两者之间合并,基本语法是

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

其中x应替换为静音的持续时间(以秒为单位)。

相关问题