I have large amount of wav files (over 50 000) and I need to split every wav file to 10 second long parts.
t's nearly impossible to do it one by one, so my question is: How can I do it in ffmpeg (or in sox)?
I have large amount of wav files (over 50 000) and I need to split every wav file to 10 second long parts.
t's nearly impossible to do it one by one, so my question is: How can I do it in ffmpeg (or in sox)?
This is mentioned as an example in man sox
:
split the input file into multiple files of 30 seconds in length. Each output filename will have unique number in its name as documented in the Output Files section.
sox infile.wav output.wav trim 0 30 : newfile : restart
So, assuming your wav files are under directory ~/myfiles
, and you want to create the split versions in ~/split
you can do
mkdir ~/split
cd ~/myfiles
find . -name '*.wav' \
-exec sh -c 'mkdir -p ~/split/$(dirname "{}")' \; \
-exec sox {} ~/split/{} trim 0 10 : newfile : restart \;