views:

109

answers:

2

Is there a way to determine an MP3 file's encoded bit depth (ie 8, 16, 24, 32) in Python using the Mutagen library?

A: 

I've not heard "bit depth" with regard to mp3s so I'm assuming you mean bit rate. From the Mutagen tutorial:

from mutagen.mp3 import MP3
audio = MP3("example.mp3")
print audio.info.length, audio.info.bitrate

That second portion (audio.info.bitrate) should be what you need.

Daniel DiPaolo
Yeah, I've definitely been able to discover MP3 bitrates using Mutagen, it's pretty easy like you demonstrated :) I would, however, like to know if the audio is 8bit, 16bit, or 24bit. I've been able to get sample rate, bit rate, but I can't seem to find a way to get bit depth.
TK Kocheran
+1  A: 

The transformations done by the MP3 encoding process drop completely the concept of “bit depth”. You can only know the bit depth of the source audio if such information was stored in a tag of the MP3 file. Otherwise, you can take the MP3 data and produce 8-bit, 16-bit or 24-bit audio.

ΤΖΩΤΖΙΟΥ