How to trim a wave audio in multiple time span with CLI in one line

I have a wave audio file that I want to trim in multiple points like this.

The audio is 1 hour long and I want to have first 3 minutes and from 6 min to 30 min. In another word, I want to remove 3 min to 6 min and 30 min to 60 min.

I can do with ffmpeg like this.

ffmpeg -i audio.wav -t 00:03:00 -c copy 01.wav
ffmpeg -i audio.wav -ss 00:06:00 -t 00:24:00 -c copy 02.wav
ffmpeg -i 01.wav -i 02.wav -filter_complex '[0:0][1:0]concat=n=2:v=0:a=1[out]' -map '[out]' output.wav

But if possible I want to write it in a line with options. I don't insist to use ffmpeg if it can be used from command line.

Is there way to do this?


Solution 1:

Use Sox. The command would be:

sox inputfile.wav outputfile.wav trim 0 =3:00 =6:00 =24:00

for your example. See here.

In the trim parameters every pair of values are in to out. 0 is in point, 3:00 outpoint then 6:00 inpoint and 24:00 outpoint. The = sign means relative to beginning.