Reputation: 8237
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?
Upvotes: 4
Views: 1457
Reputation: 8237
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
Upvotes: 3
Reputation: 47099
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
Upvotes: 0