How to analyze a segment of an audio file with sox

audiosox

I wanted to analyze 5 seconds of an audio file beginning from 50 seconds.

So I ran the following command:

sox audio.wav -n stat trim 50 5

But the output contained:

...
Length (seconds):     55.296000
...

But I expected only 5 seconds, not 55.

What did I do wrong? I thought that 50 was the start and 5 – the duration.

Best Answer

The effects function as a chain, so the stat effect feeds into trim, swap them around and it will work, e.g.:

sox audio.wav -n trim 50 5 stat