Using Sox, how do I shorten an audio file by 5 seconds, trimming from the end?
For example, this is how to trim a file from the beginning:
sox input output trim 5000
This is how to add 5 seconds of silence to the end:
sox input output pad 0 5000
The syntax is
sox input output trim <start> <duration>e.g.
sox input.wav output.wav trim 0 00:35will output the first 35 seconds intooutput.wav.(you can know what the length is using
sox input -n stat)From the SoX documentation on the
trimcommand:Per dpwe’s comment, the position values are interpreted as being relative to the previous position, unless they start with
=(in which case they are relative to the start of the file) or-(in which case they are relative to the end of the file).So, trimming five seconds off the end would be
sox input output trim 0 -5