Click to See Complete Forum and Search --> : reading mp3 header
Techno
Aug 12th, 2006, 12:15 PM
I am trying to find out the bitrate of an mp3 file.
I have successfully been able to retrieve other information (name, artist, title, year etc...) but not the bitrate of an mp3 file.
how would I go about doing this?
ComputerJy
Aug 12th, 2006, 03:48 PM
How did you retrieve the other info.
If you tell us how perhaps we can help, but I don't really know how to get mp3 info
Techno
Aug 12th, 2006, 04:08 PM
the other info was retrieved by seeking 128 bytes from the file and then string parsing
FileStream theFileStream = new FileStream(@"Path\file.mp3", FileMode.Open);
Byte[] theByteBuff = new Byte[128];
theFileStream.Seek(-128, SeekOrigin.End);
theFileStream.Read(theByteBuff, 0, 128);
theFileStream.Close();
System.Text.ASCIIEncoding theEncoding = new System.Text.ASCIIEncoding();
string theTagInfo = theEncoding.GetString(theByteBuff);
if (theTagInfo.Contains("TAG"))
{
string theTitle = theTagInfo.Substring(3, 30).Trim();
string theArtist = theTagInfo.Substring(33, 30).Trim();
string theAlbum = theTagInfo.Substring(63, 30).Trim();
string theYear = theTagInfo.Substring(93, 30).Trim();
}
trust me, its not there (bitrate)
Negative0
Aug 14th, 2006, 01:04 PM
Here is the information about the file format. It should give you enough information to get started on what you should be reading:
http://www.dv.co.yu/mpgscript/mpeghdr.htm
However, if you only sample one frame of data, your #s might not be correct because of the ability of MP3 files to have a variable bitrate.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.