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

0

1

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?

ironsand

Posted 2013-11-16T02:05:59.767

Reputation: 1 757

If you are on linux you can use && to join your three command lines. See this discussion.

– Rajib – 2013-11-16T13:27:42.670

Sorry, I should have state more clearly what I want. I know about &&, but I wanted to know there is a way to write it more easily with some options in a command. I rewrote my question a little. – ironsand – 2013-11-17T12:40:38.500

Not sure I understand what you want. More easily than &&? Not ffmpeg? Or do you mean no intermediate storage into temp files? – Rajib – 2013-11-17T15:39:41.990

I thought maybe there is a command that trim and concatenate a audio with like this, audiotrimer audio.wav --from 0min -t 3min --from 6min -t 24min output.wav. – ironsand – 2013-11-18T00:56:21.627

Answers

3

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.

Rajib

Posted 2013-11-16T02:05:59.767

Reputation: 2 406