Reputation: 7218
From this stack post I see how to supposedly trim silence of 0.1 seconds or longer using sox.
sox inputfile.mp3 outputfile.mp3 silence 1 0.1 0.1% reverse silence 1 0.1 0.1% reverse
One problem is that the command above does absolutely nothing, in my mp3 file, which has silent chunks as long as 3 seconds.
I want to trim all silence from my MP3s in which the current silence is equal to or greater than 0.75 seconds. So I interpolated from the above to be:
sox inputfile.mp3 outputfile.mp3 silence 1 0.75 0.75% reverse silence 1 0.75 0.75% reverse
...but I'm pretty sure I'm getting that wrong because I don't really know what I'm doing, and I'm unsure what the % params mean, and it does nothing to my mp3 anyway. What would be the corrected [full] cmd-line usage to trim all chunks of silence >= 0.75 seconds?
Also I would love it if you could explain what each param means. I read the docs on this silence
command in sox, but I'm not really understanding.
Important: All my audio files will have chunks of silence scattered throughout, not at the beginning/end of the tracks.
Upvotes: 2
Views: 3196
Reputation: 2631
You have to first break it into multiple pieces, then merge the pieces back together:
sox inputfile.mp3 tmpoutput.mp3 silence 1 0.75 0.1% 1 0.75 0.1% : newfile : restart
sox -m tmpoutput*.mp3 output.mp3
rm tmpoutput*.mp3
Upvotes: 1
Reputation: 3593
I found this very useful guide for using SoX Silence. While the official SoX Silence manual page is quite a mess and incomprehensible, this guide provides thorough explanation with examples: https://digitalcardboard.com/blog/2009/08/25/the-sox-of-silence/comment-page-2/
It seems you want to do:
sox inputfile.mp3 outputfile.mp3 silence 1 0.75 0.1% 1 0.75 0.1% : newfile : restart
This will break the audio into pieces with the silences in the middle removed. Then you can simply combine them into one file again.
Upvotes: 4