When the metadata is not really required, you can eliminate it. In this article, we will learn how to programmatically remove different MP3 tags in Java. Precisely, we will see the removal of ID3v1, ID3v2, Lyrics, and APEv2 metadata tags from mp3 files within the Java application.

The following topics are covered below:

Java API for MP3 Tags Removal

GroupDocs.Metadata provides metadata management Java API to deal with metadata of different file formats. GroupDocs.Metadata for Java allows to read, update, add, clean, and totally remove the metadata for various file formats. I will use this API to remove metadata tags of MP3 files.

Download or Configure

You may download the JAR file from the downloads section, or just get the repository and dependency configurations for the pom.xml of your maven-based Java applications.

<repository>
	<id>GroupDocsJavaAPI</id>
	<name>GroupDocs Java API</name>
	<url>http://repository.groupdocs.com/repo/</url>
</repository>
<dependency>
        <groupId>com.groupdocs</groupId>
        <artifactId>groupdocs-metadata</artifactId>
        <version>21.8</version> 
</dependency>

Remove MP3 Tags in Java - ID3v1, ID3v2, Lyrics, APE

The following steps will quickly allow you to remove MP3 metadata tags from your MP3 files in Java.

  1. Load the MP3 file.
  2. Get the MP3 root package.
  3. Remove the relevant MP3 Tag(s).
  4. Save the updated MP3 file.

1. Load MP3

Select the MP3 file and load it using the Metadata class.

Metadata metadata = new Metadata("path/mp3File.mp3");

2. Get MP3 Root Package

Get the MP3 Root Package of the MP3 file using the getRootPackageGeneric() method.

MP3RootPackage root = metadata.getRootPackageGeneric();

3. Remove MP3 Tags

Following are ways to remove different metadata tags. You can use the relevant removal method for your MP3 files.

ID3v1

To remove the ID3v1 metadata tags, set the ID3V1 property of the root package to null.

root.setID3V1(null);

ID3v2

Set the ID3V2 property to null to remove the ID3v2 metadata tags.

root.setID3V2(null);

Lyrics

Remove the Lyrics tags by setting the Lyrics Tag to null.

root.setLyrics3V2(null);

APE

Use the removeApeV2() method of the root package to eliminate APEv2 tags.

root.removeApeV2();

4. Save the File

Lastly, save the updated MP3 file using the save() method.

metadata.save("path/mp3TagsRemoved.mp3");

Complete Code - Remove MP3 Tags

The following Java source code example shows how to remove relevant MP3 Tags from the MP3 files.

Get a Free API License

You can get a free temporary license to use the API without the evaluation limitations.

Conclusion

To conclude, we learned to remove metadata tags from MP3 files in Java using Metadata API. One by one, we looked into how to remove ID3v1, ID3v2, Lyrics, and APE tags from the MP3 files.

You can learn more about the API from the documentation. Contact us for queries via the forum.

See Also