Question

I've got a bunch of wav files I'd like to pad with silence to make them exactly the same length. Ideally I want to do this from the command-line.

I've tried using sox's pad command, but that only adds a fixed length of silence. Is there any way I can get it to just pad to a fixed length?

Was it helpful?

Solution

Ok, I've solved this a noddy way - create a file of the appropriate amount of silence (by using pad and trim on any random file), then mix it with the input file with:

sox -m -v 1 input.wav silence.wav output.wav

OTHER TIPS

The pad effect doesn't support relative to total length specification. You could calculate the needed length in number of samples, assuming bash scripting is available (not tested):

total_length=48000
pad_len=$(( total_length - $(soxi -s file_to_pad.wav) ))
sox file_to_pad.wav file_padded.wav pad 0 $pad_len
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top