javaandroidaudioffmpegmp3

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


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


Solution

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