20

Currently we're using this command within a shell script to remove silence from audio files:

ffmpeg -i $INFILE -af silenceremove=0:0:0:-1:1:${NOISE_TOLERANCE}dB -ac 1 $SILENCED_FILE -y

This works fine except that it removes all the silence, causing the remaining audio to be squeezed together.

How can this be done while leaving two or three seconds between each piece of audio?

The solution needs to be very efficient as we'll be processing a lot of audio and should use a tool that can be fairly easily installed on both Linux and OSX, such as ffmpeg or sox.

1 Answer 1

27

The best way that I've seen is by adding the -l flag to silence as follows:

sox in.wav out6.wav silence -l 1 0.1 1% -1 2.0 1%

I've copied this command from Example 6 of this very useful blog post called The Sox of Silence

2
  • I'd like to do this for a video and trim the silence - will SoX work? What is the best alternative?
    – zero_cool
    May 5, 2019 at 17:18
  • Note the difference between -l (L) and -1 (one) (both appear in the command above)
    – kuropan
    Jun 5, 2021 at 10:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .