Delete the silence at the beginning and end of an audio file with SoX

Published by TheJoe on

Estimated reading time: 2 minutes


This article was published more than a year ago, there may have been developments.
Please take this into account.

SoX It is a tool for Editing audio files via the command line in Linux. Some past projects will allow the use through GUI, but they were in time abandoned all and there remained only the command line (not that I mind).

Often the audio file is set to a silent too long beginning or end of the file. HE, as in my case, the files are queued in audio player, or on a CD the wait is nervous. SoX well as do virtually anything with audio files, It allows you to remove the silence in the input and output, returning a file ready to be queued or burn (and often much lighter original).

Thus we see how to proceed:

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

The above command invokes SoX, enter the file “inputfile.mp3“, returns “outputfile.mp3“, cuts beginning of the file everything that has less than 1% of the total volume, until it encounters a sound that lasts more than 0.1 seconds. “Reverse” It executes the command again from the bottom.

The file before the SoX
The file before the SoX
The file after starting SoX
The file after starting SoX

For those wishing to convert all files in a given directory at once the command to run is as follows:

for file in *.mp3; do sox "$file" "nosilence / ${file%.mp3}.mp3" silence 1 0.1 1% reverse silence 1 0.1 1% reverse; done

It'll be a directory created previously(in my case “nosilence“) the directory where we will launch the command.

Look here:  Temp-throttle: a CLI utility to avoid PC fever

Insights intothis article, that's just the filter “silence” SoX. It is to get an education.


I keep this blog as a hobby by 2009. I am passionate about graphic, technology, software Open Source. Among my articles will be easy to find music, and some personal thoughts, but I prefer the direct line of the blog mainly to technology. For more information contact me.


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.