Click here to Skip to main content
Click here to Skip to main content

Read MP3 header information and read/write the ID3v1 tag

, 1 Mar 2005
Rate this:
Please Sign up or sign in to vote.
A small solution for reading MPEG audio headers and the ID3v1 tag


There are many other articles at The Code Project describing the audio header and tag information, but none in VB.NET. So it's time to update my very old article (Reading and writing MP3 ID3v1 tags ) with nicer code and extend it to read the MPEG header information.

I don't want to go into detail about the structure of MPEG audio headers, because Konrad Windszus already has a very good article (MPEG Audio Frame Header) about that. If you're interested in the structure of the audio header or the ID3 tag format i recommend to visit the following sites:

Using the code

I wrote two classes to handle the header and tag information, called MP3Info and ID3v1Tag. The following code will show the structure to use the classes:

Dim objMP3Info As New _
With ListView1
    ''' Set the filename property
    objMP3Info.Filename = "c:\test.mp3"

    ''' Add the header information to a listview
    .Add("Filesize").SubItems.Add(objMP3Info.Filesize & " Byte")
    .Add("SamplingRateFrequency").SubItems.Add _
     (objMP3Info.SamplingRateFrequency & " Hz")
    .Add("Padding").SubItems.Add(objMP3Info.Padding & " Bytes")
    .Add("Bitrate").SubItems.Add(objMP3Info.Bitrate & " bps")
    .Add("FrameSize").SubItems.Add(objMP3Info.FrameSize & " Byte")
    .Add("Length").SubItems.Add(objMP3Info.Length & " s (" 
     & Int(objMP3Info.Length / 60) & ":" & _
      objMP3Info.Length Mod 60 & " m)")

    Select Case objMP3Info.MPEGVersion
        Case MP3.MPEGVersionEnum.MPEG1
            .Add("MPEGType").SubItems.Add("MPEG 1")
        Case MP3.MPEGVersionEnum.MPEG2
            .Add("MPEGType").SubItems.Add("MPEG 2")
        Case MP3.MPEGVersionEnum.MPEG25
            .Add("MPEGType").SubItems.Add("MPEG 2.5")
    End Select

    Select Case objMP3Info.Layer
        Case MP3.LayerEnum.LayerI
            .Add("Layer").SubItems.Add("Layer I")
        Case MP3.LayerEnum.LayerII
            .Add("Layer").SubItems.Add("Layer II")
        Case MP3.LayerEnum.LayerIII
            .Add("Layer").SubItems.Add("Layer III")
    End Select

    Select Case objMP3Info.Protection
        Case MP3.ProtectionEnum.None
        Case MP3.ProtectionEnum.CRC
            .Add("Protection").SubItems.Add("By CRC")
    End Select

    Select Case objMP3Info.ChannelMode
        Case MP3.ChannelModeEnum.DualChannel
            .Add("ChannelMode").SubItems.Add("Dual Channel")
        Case MP3.ChannelModeEnum.JointStereo
            .Add("ChannelMode").SubItems.Add("Joint Stereo")
        Case MP3.ChannelModeEnum.SingleChannel
            .Add("ChannelMode").SubItems.Add("Single Channel")
        Case MP3.ChannelModeEnum.Stereo
    End Select

    Select Case objMP3Info.Emphasis
        Case MP3.EmphasisEnum.CCIT
        Case MP3.EmphasisEnum.MS5015
            .Add("Emphasis").SubItems.Add("50/15 ms")
        Case MP3.EmphasisEnum.None
    End Select

    Select Case objMP3Info.Encoding
        Case MP3.EncodingEnum.CBR
        Case MP3.EncodingEnum.VBR
    End Select

    ''' Add the ID3v1 tag information to a listview
    If (objMP3Info.ID3v1Tag.TagAvailable) Then
        .Add("ID3 Title").SubItems.Add _
    End If

    ''' Update the tag
    objMP3Info.ID3v1Tag.Title = "Another title"

End With

Please have a look at the sample and the class code to see all the features.

Points of Interest

Unlike other articles, this class will handle CBR and VBR encoded files, so the playtime is calculated correctly.

The class is well-commented with XML comments made by AxTools CodeSmart 2005 and NDoc . I included the generated HTML help file in the download.

I'm working on reading and writing the much more complex ID3v2.x tags at the moment (80% done, just compressed frames are a little bit tricky). If you are interested in this, i will update this article in the future.


27.02.2004 Release of version 1


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Thommy Mewes
Software Developer (Senior) CIBER AG
Germany Germany
Feel free to contact me via Email or MSN Messenger (
Follow on   Twitter

Comments and Discussions

QuestionAlbum art Pinmemberraghubirdevnet16-Oct-12 1:02 
GeneralCRC Protection? PinmemberMember 357297015-May-11 15:19 
GeneralIDv2 PinmemberSousuke_31-Aug-10 11:35 
QuestionWie kann ich Änderungen speichern? MP3 Pinmembermichaelroswitha13-Jan-10 9:25 
QuestionHow to read the actual genre string when it is "other" Pinmembera1penguin18-Jun-09 18:05 
GeneralVBR File Pinmembernitesh gaba19-Mar-09 22:30 
QuestionWhat i write to the tag doesn't show up when viewing the property details in the file system. PinmemberMattRoy1018-Mar-09 15:11 
AnswerRe: What i write to the tag doesn't show up when viewing the property details in the file system. Pinmembermazin221-Dec-10 14:11 
Generalhip hop songs and dance PinmemberJigga Hov12-Dec-08 6:58 
GeneralGNU OpenSource Tag Library for .NET Pinmembersomeonestupid196910-Dec-08 5:55 
GeneralSet mp3-Tag with objMP3Info Pinmembersquirrel9128-Jul-07 0:45 
QuestionIs it? PinmemberRola /anglian/12-Jun-07 1:03 
GeneralRemote MP3 Pinmemberohadioe230-Apr-07 6:33 
GeneralOverFlow searching Genres Pinmemberricsamma15-Nov-06 18:25 
AnswerRe: OverFlow searching Genres PinmemberThommy Mewes15-Nov-06 21:39 
GeneralAdding Info to a listbox PinmemberJohn Dovey7-Sep-06 3:36 
QuestionHow to use this dll in Exel Macro? Pinmemberstrangerland26-May-06 19:16 
AnswerRe: How to use this dll in Exel Macro? [modified] Pinmemberbill-tor4-Jan-07 18:50 
GeneralBitrate problem PinmemberAlberto Venditti15-Feb-06 10:12 
GeneralRe: Bitrate problem PinmemberAndyLang15-Jul-07 16:17 
GeneralRe: Bitrate problem PinmemberLegoMindstorms5-Apr-08 11:44 
GeneralRe: Bitrate problem Pinmembervardos10-Sep-11 0:51 
QuestionUpdate Missing PinmemberIftikhar Ali17-Jan-06 0:54 
AnswerRe: Update Missing PinmemberThommy Mewes17-Jan-06 9:44 
GeneralRe: Update Missing PinmemberIftikhar Ali17-Jan-06 21:33 
QuestionRe: Update Missing Pinmembermazin221-Dec-10 14:08 
AnswerRe: Update Missing PinmemberEsquilax19793-Nov-11 9:29 
QuestionPassword??? PinmemberGodz1lla1-Jan-06 13:44 
AnswerRe: Password??? PinmemberThommy Mewes17-Jan-06 9:45 
GeneralException by reading header info from CD PinmemberRonny Foerster29-May-05 21:03 
GeneralRe: Exception by reading header info from CD PinmemberThommy Mewes16-Jun-05 13:21 
GeneralRe: Exception by reading header info from CD PinmemberJef Lagueux21-Mar-06 13:59 
QuestionRe: Exception by reading header info from CD PinmemberKaosKidd7-Dec-06 5:11 
GeneralRe: Exception by reading header info from CD Pinmembercicijay5-Aug-07 10:32 
QuestionWhat kind of listview do you use Pinmemberratel330-Apr-05 21:06 
AnswerRe: What kind of listview do you use PinmemberThommy Mewes1-May-05 11:34 
AnswerRe: What kind of listview do you use Pinmemberratel35-May-05 3:42 
GeneralRe: What kind of listview do you use PinmemberXDG24-May-05 3:02 
QuestionID3V2 support? PinmemberEdwardA30-Mar-05 9:07 
AnswerRe: ID3V2 support? PinmemberThommy Mewes30-Mar-05 9:53 
GeneralRe: ID3V2 support? PinmemberXDG23-May-05 8:10 
GeneralRe: ID3V2 support? PinsussAnonymous27-May-05 23:51 
GeneralRe: ID3V2 support? PinmemberThommy Mewes16-Jun-05 13:22 
QuestionRe: ID3V2 support? Pinmembercrouchie199818-Oct-05 13:44 
AnswerRe: ID3V2 support? Pinmemberemkarwin29-Aug-07 22:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150129.1 | Last Updated 1 Mar 2005
Article Copyright 2005 by Thommy Mewes
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid