How to trim silence only from beginning and end of mp3 files using FFMpeg?

Something like this:

ffmpeg -i input.mp3 -af "silenceremove=start_periods=1:start_duration=1:start_threshold=-60dB:detection=peak,aformat=dblp,areverse,silenceremove=start_periods=1:start_duration=1:start_threshold=-60dB:detection=peak,aformat=dblp,areverse" output.flac

You'll need to adjust both thresholds (start_threshold) and durations (start_duration) to your specific case.


FWIW, while the original question specifically requests using ffmpeg, there is a tool called mp3splt which will trim silence ( -r ) without reencoding the mp3. This leaves the original quality of your mp3 intact.