Results 1 to 4 of 4

Thread: reading mp3 header

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    reading mp3 header

    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?

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: reading mp3 header

    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
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: reading mp3 header

    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)

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  4. #4
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: reading mp3 header

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width