When you download an audio file from the internet or record an audio for a podcast, it very likely that the beginning or the ending of the audio file are blank audio.

What if you wanted the audio file to start exactly when the audible portion of the audio starts and end exactly when the audio sound ends and leave no trailing blank audio. There are two ways you can achieve this.

One would be to manually trim it using an audio editing software such as Audacity or Adobe Audition. The other way would be to automatically detect the silence and trim it.

We will be exploring the latter method in this article.


To achieve this we will use the silenceremove filter in ffmpeg

ffmpeg -i input.mp3 -af \
start_threshold=-50dB,areverse \

You will need to adjust both start_threshold and start_duration to your specific use case.