How to get the volume of MP3 file?
I need to get the开发者_高级运维 average volume of the mp3 file in dB. This must be that when listening to multiple files automatically adjust the volume. In this case, the files themselves do not need to normalize. Ideally, I need to get a result in the command line, but fit and just an algorithm.
The stat
predicate of SoX gives all sorts of statistics about an audio stream:
sox <file.mp3> -n stat
Some answers here: calculate mp3 average volume
Could be useful: http://normalize.nongnu.org/
Check out the Replay Gain standard. Audio players such as foobar2000 can apply the algrorithm to your ripped CDs or music collection to normalize the average volumes of tracks at track-scope or album-scope without changing the audio content of the files.
From the HydrogenAudio Wiki:
Replay Gain is the name of a technique invented to achieve the same playback volume of audio files. It specifies the reference level of 89dB and an algorithm to measure the perceived loudness of audio data.
Replay Gain allows the loudness of each song within a collection of songs to be consistent. This is called 'Track Gain', or 'Radio Gain' in earlier parlance. It also allows the loudness of a specific sub-collection (an "album") to be consistent with the rest of the collection, while allowing the dynamics from song to song on the album to remain intact. This is called 'Album Gain', or 'Audiophile Gain' in earlier parlance. This is usually important when listening to classical music albums, because quiet tracks need to remain a certain degree quieter than the louder ones.
Replay Gain is different from peak normalization. Peak normalization merely ensures that the peak amplitude reaches a certain level. This does not ensure equal loudness. The Replay Gain technique measures the effective power of the waveform (i.e. the RMS power after applying an "equal loudness contour"), and then adjusts the amplitude of the waveform accordingly. The result is that Replay Gained waveforms are usually more uniformly amplified then peak-normalized waveforms.
The wiki page also lists various implementations and related tools. Maybe one of these will be right for you!
精彩评论