I would like to get the sample-rate of a given audio file using sox. Couldn't find the commandline to do that.
Asked
Active
Viewed 4.7k times
1 Answers
79
just use:
soxi <filename>
or
sox --i <filename>
to produce output such as:
Input File : 'final.flac'
Channels : 4
Sample Rate : 44100
Precision : 16-bit
Duration : 00:00:11.48 = 506179 samples = 860.849 CDDA sectors
File Size : 2.44M
Bit Rate : 1.70M
Sample Encoding: 16-bit FLAC
Comment : 'Comment=Processed by SoX'
The latter one is in case you're using the win32 version that doesn't include soxi, by default. To grab the sample rate only, just use:
soxi -r <filename>
or
sox --i -r <filename>
which will return the sample rate alone.
-
You know how you would ask JUST for the bit rate in such a way that the output could be read by a PHP script? For instance, it would just return "44100" instead of Sample Rate : 44100 – Scott Jan 10 '11 at 13:44
-
3I made an edit, but in case it doesn't get approved, to get the sample rate alone, you can use: `soxi -r
` which will show `16000` alone. Also, in case you're using the win32 version, which doesn't include `soxi` by default, you can just use: `soxi --i – cesar Jul 30 '11 at 08:48` or `soxi --i -r ` The first shows the formatted metadata, while the second shows the sample rate alone. -
Note that this `sox` program isn't included in OSX. You can install it with `brew install sox` if you use homebrew. – David Tuite May 17 '13 at 17:03
-
How to check the sample rate spectrum using sox – optimus prime Jun 09 '16 at 06:29