2

I need to split wav files into multiple 10-second-long wav files, but each resulting wav file must be exactly 10 seconds in length, adding silence if needed – so if a wav file's duration in seconds isn't a multiple of 10, the last wav file should be padded with silence.

I've seen some answers (1, 2, 3) which show how to use sox and ffmpeg to split a file into chunks of equal length:

$ ffmpeg -i file.wav -f segment -segment_time 10 -c copy out%03d.wav
$ sox file.wav output-.wav trim 0 10 : newfile : restart            

but the last file produced by these commands is usually less than 10 seconds long. Is there a way to split a wav file, padding the last file if needed, in the same command?

Eric
  • 123

1 Answers1

2

Split the files, inspect the resulting files (for i in *wav), if (length < 10 seconds), pad them.

Maybe do some calculations :-)