Handling the ID3v1 tag
Leave feedback
ID3v1 is a metadata tag that is usually used with MP3 audio files. The whole tag occupies 128 bytes and allows adding metadata properties such as title, artist, album, track number, etc.The ID3v1 standard was introduced in 1996 but it’s still widely supported by various audio players and decoders. To get more information about ID3v1 tags please visit http://id3.org/ID3v1.
The following steps show how to read the ID3v1 tag in an MP3 file.
- Load an MP3 file
- Extract the root metadata package
- Get the ID3v1 tag by using the Mp3RootPackage.ID3V1 property
- If the ID3v1 tag is not null then check for all of its properties
AdvancedUsage.ManagingMetadataForSpecificFormats.
using (Metadata metadata = new Metadata(Constants.MP3WithID3V1))
{
var root = metadata.GetRootPackage<MP3RootPackage>();
if (root.ID3V1 != null)
{
Console.WriteLine(root.ID3V1.Album);
Console.WriteLine(root.ID3V1.Artist);
Console.WriteLine(root.ID3V1.Title);
Console.WriteLine(root.ID3V1.Version);
Console.WriteLine(root.ID3V1.Comment);
// ...
}
}
The following are the steps to update the ID3v1 tag in an MP3 file.
- Load an MP3 file
- Extract the root metadata package
- Create the ID3v1 tag if it’s missing
- Update ID3v1 fields using the Mp3RootPackage.ID3V1 property
- Save the changes
The following code snippet shows how to update the ID3v1 tag in an MP3 file.
AdvancedUsage.ManagingMetadataForSpecificFormats.
using (Metadata metadata = new Metadata(Constants.MP3WithID3V1))
{
var root = metadata.GetRootPackage<MP3RootPackage>();
if (root.ID3V1 == null)
{
root.ID3V1 = new ID3V1Tag();
}
root.ID3V1.Album = "test album";
root.ID3V1.Artist = "test artist";
root.ID3V1.Title = "test title";
root.ID3V1.Comment = "test comment";
root.ID3V1.Year = "2019";
// ...
metadata.Save(Constants.OutputMp3);
}
To remove the ID3v1 tag from an MP3 audio just assign null to the Mp3RootPackage.ID3V1 property. The code sample below shows how to remove the ID3v1 tag from an MP3 file.
AdvancedUsage.ManagingMetadataForSpecificFormats.
using (Metadata metadata = new Metadata(Constants.MP3WithID3V1))
{
var root = metadata.GetRootPackage<MP3RootPackage>();
root.ID3V1 = null;
metadata.Save(Constants.OutputMp3);
}
You may easily run the code above and see the feature in action in our GitHub examples:
The MP3 Metadata Editing app is available to view and edit metadata of MP3 audio files, including title, artist, album, genre, and other ID3 tags.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.