Handling the ID3v1 tag

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Metadata MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-metadata -- dnx GroupDocs.Metadata.Mcp --yes
Folders, licensing and more →

What is ID3v1?

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.

Reading an ID3v1 tag

The following steps show how to read the ID3v1 tag in an MP3 file.

  1. Load an MP3 file
  2. Extract the root metadata package
  3. Get the ID3v1 tag by using the Mp3RootPackage.ID3V1 property
  4. If the ID3v1 tag is not null then check for all of its properties

AdvancedUsage.ManagingMetadataForSpecificFormats.Audio.MP3.MP3ReadID3V1Tag

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);

		// ...
	}
}

Updating an ID3v1 tag

The following are the steps to update the ID3v1 tag in an MP3 file.

  1. Load an MP3 file
  2. Extract the root metadata package
  3. Create the ID3v1 tag if it’s missing
  4. Update ID3v1 fields using the Mp3RootPackage.ID3V1 property
  5. Save the changes

The following code snippet shows how to update the ID3v1 tag in an MP3 file.

AdvancedUsage.ManagingMetadataForSpecificFormats.Audio.MP3.MP3UpdateID3V1Tag

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);
}

Removing an ID3v1 tag

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.Audio.MP3.MP3RemoveID3V1Tag

using (Metadata metadata = new Metadata(Constants.MP3WithID3V1))
{
	var root = metadata.GetRootPackage<MP3RootPackage>();
	root.ID3V1 = null;
	metadata.Save(Constants.OutputMp3);
}

More resources

GitHub examples

You may easily run the code above and see the feature in action in our GitHub examples:

MP3 metadata management demo App

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.