How can I remove silence from an MP3 programmatically?

人走茶凉 提交于 2019-11-28 18:43:21
sox inputfile.mp3 outputfile.mp3 silence 1 0.1 0.1% reverse silence 1 0.1 0.1% reverse

This will trim any silence longer than 0.1 second from your file. If you're only concerned about trimming the end, this can be simplified to:

sox inputfile.mp3 outputfile.mp3 reverse silence 1 0.1 0.1% reverse

A detailed look into how sox's silence works can be found here.

You probably are looking for a lossless solution, i.e. one that does not require re-encoding (which reduces quality).

I believe mp3splt is what you are looking for. It can be used from command line and GUI.

sudo aptitude install mp3splt mp3splt-gtk

should work on Debian and Ubuntu.

From the man page:

You can also try to split files automatically with silence detection (see -s option), trim files using silence detection (see -r option), or by a fixed time length (see -t option)

Have a look at the silencedetect FFmpeg audio filter:

Detect silence in an audio stream.

This filter logs a message when it detects that the input audio volume is less or equal to a noise tolerance value for a duration greater or equal to the minimum detected noise duration.

The printed times and duration are expressed in seconds.

It has parameters to adjust how quiet something has to be to be considered silence, and how long the silence needs to be to be noted.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!