MP3 files could contain metadata of various standards. Sometimes you do not require certain metadata information. We can quickly remove these metadata MP3 tags programmatically. In this article, we will discuss how to remove different MP3 tags using C#. Precisely, we will learn to remove ID3v1, ID3v2, Lyrics, and APEv2 metadata tags from the mp3 files within the .NET application.
The following topics are covered below:
.NET API for MP3 Tags Removal
GroupDocs.Metadata showcases metadata management .NET API to deal with various file formats within .NET applications. The API allows to read, update, add, clean, and totally remove the metadata for many file formats. We will use this API to remove metadata tags of MP3 files.
You can download the DLLs or MSI installer from the downloads section or install the API in your .NET application via NuGet.
PM> Install-Package GroupDocs.Metadata
Remove MP3 Tags using C# – ID3v1, ID3v2, Lyrics, APE
The following steps will quickly allow you to remove MP3 metadata tags from your MP3 files in C#.
- Load the MP3 file.
- Get the MP3 root package.
- Remove the relevant MP3 Tag(s).
- 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 GetRootPackage() method.
var root = metadata.GetRootPackage();
3. Remove MP3 Tags
From the following ways of removing different metadata tags, you can use your relevant removal strategy.
ID3v1
To remove the ID3v1 metadata tags, set the ID3V1 property of the root package as null.
root.ID3V1 = null;
ID3v2
To remove the ID3v2 metadata tags, nullify the ID3V2 property.
root.ID3V2 = null;
Lyrics
Remove the Lyrics tags by setting the Lyrics3V2 property to null.
root.Lyrics3V2 = 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
The following source code example shows how to remove relevant MP3 Tags from the MP3 file in C#.
Get a Free API License
You can get a free temporary license to use the API without the evaluation limitations.
Conclusion
To sum up, we learned to remove metadata tags from the MP3 files using C#. We specifically removed ID3v1, ID3v2, Lyrics, and APE tags from the MP3 files. You can learn more about the API from the documentation and contact us for queries via the forum.