Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get length of .wav from sox output

I need to get the length of a .wav file.

Using:

sox output.wav -n stat 

Gives:

Samples read:            449718 Length (seconds):     28.107375 Scaled by:         2147483647.0 Maximum amplitude:     0.999969 Minimum amplitude:    -0.999969 Midline amplitude:     0.000000 Mean    norm:          0.145530 Mean    amplitude:     0.000291 RMS     amplitude:     0.249847 Maximum delta:         1.316925 Minimum delta:         0.000000 Mean    delta:         0.033336 RMS     delta:         0.064767 Rough   frequency:          660 Volume adjustment:        1.000 

How do I use grep or some other method to only output the value of the length in the second column, i.e. 28.107375?

Thanks

like image 761
joshu Avatar asked Dec 26 '10 15:12

joshu


People also ask

How do I find the length of an audio file?

To determine the file size of an audio file, we have to multiply the bit rate of the audio by its duration in seconds. As a result, we get file size values in terms of kilobits and megabits.

How many bits is a WAV file?

The WAV format is by definition, the highest quality 16-bit audio format. It is also the largest at about 10 MB per minute of CD quality audio. The quality can be sacrificed for file size by adjusting the sampling rate, data width (i.e. 8-bits), and number of channels (up to 2 for stereo).


1 Answers

There is a better way:

soxi -D out.wav 
like image 129
Andrew Kuklewicz Avatar answered Sep 23 '22 10:09

Andrew Kuklewicz