Handling the APEv2 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 APEv2?

The APE tag is a standard used to add metadata, such as the title, artist, or track number, to digital audio files. The APEv1 tag was designed for the Monkey’s Audio format. In MP3 files, the APE tag was originally stored at the very end of the file, with no inline declaration in the body of the file. But later the standard was extended to add a header, allowing APE tags to be at the beginning of files and allowing metadata values to be Unicode rather than simply ASCII. The improved standard is called APEv2. 

Note
Please find more information at https://en.wikipedia.org/wiki/APE_tag

Reading an APEv2 tag

The GroupDocs.Metadata API allows reading the APEv2 tag in an MP3 audio.

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

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

AdvancedUsage.ManagingMetadataForSpecificFormats.Audio.MP3.MP3ReadApeTag

using (Metadata metadata = new Metadata(Constants.MP3WithApe))
{
	var root = metadata.GetRootPackage<MP3RootPackage>();

	if (root.ApeV2 != null)
	{
		Console.WriteLine(root.ApeV2.Album);
		Console.WriteLine(root.ApeV2.Title);
		Console.WriteLine(root.ApeV2.Artist);
		Console.WriteLine(root.ApeV2.Composer);
		Console.WriteLine(root.ApeV2.Copyright);
		Console.WriteLine(root.ApeV2.Genre);
		Console.WriteLine(root.ApeV2.Language);

		// ...
	}
}

Removing an APEv2 tag

The GroupDocs.Metadata API supports removing the APEv2 tag from an MP3 audio.

The following are the steps to remove the APEv2 tag from an MP3 file.

  1. Load an MP3 file
  2. Get the root metadata package
  3. Remove the tag by calling the RemoveApeV2 method
  4. Save the changes

AdvancedUsage.ManagingMetadataForSpecificFormats.Audio.MP3.MP3RemoveApeTag

using (Metadata metadata = new Metadata(Constants.MP3WithApe))
{
	var root = metadata.GetRootPackage<MP3RootPackage>();

	root.RemoveApeV2();

	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.