15

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.

23

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

  • Tested, and does exactly what I need. Thank you! – Nathan Arthur Jul 4 '16 at 20:05
  • Finally a solution on how it works. Thanks. – vr_driver Nov 22 '17 at 8:52
  • 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 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.