given that I have a .wav file, which would be the best way to read its bit rate property in C #. I tried Shell and asked the question Is the "Bit rate" property fixed at index 28? without any changes. I also now believe that Shell is not the best way to read the properties of an audio file. I have researched various open source libraries, can't find much.
TagLib #: This one works well, but has two problems. it does not reflect the actual bit rate in some cases, when the bit rate is very low (for example, less than 30), it just returns 0. Secondly, I'm not sure if I can use it for commercial use. License reads http://opensource.org/licenses/LGPL-2.1
NAudio: just doesn’t disclose any property to read the bit rate, so I have to calculate it. after research, I got this formula for calculating the bit rate. bitrate = Samplerate * Channels * BitsPerSample. This works fine in most cases, but it doesn't work if you get BitsPerSample = 0 for some .wav files. Yes, the file is absolutely right, I can play it, but BitsPerSample is still 0.
MediaInfo: again, there is no direct property, you need to iterate over all the properties of the audio file, and then look for the "total transfer rate". in addition, you need to add two dll libraries to the project, one is the.net wraper and the other is the actual dll.
Sorry for such a long resume, but I didn’t want to ask “hey how can I get the bitrate of the audio file” without showing what I already did. So, if you have a .wav audio file, which library / method would you use to get the bitrate?
source
share