(aka Taglib-sharp) is a .NET platform-independent library (tested on Windows/Linux) for reading and writing metadata in media files, including video, audio, and photo formats. This is a convenient one-stop-shop to present or tag all your media collection, regardless of which format/container these might use. You can read/write the standard or more common tags/properties of a media, or you can also create and retrieve your own custom tags.
It supports the following formats (by file-extensions):
It is API stable, with only API additions (not changes or removals) occuring in the 2.0 series.
var tfile = TagLib.File.Create(@"C:\My video.avi");
string title = tfile.Tag.Title;
TimeSpan duration = tfile.Properties.Duration;
Console.WriteLine("Title: {0}, duration: {1}", title, duration);
// change title in the file
tfile.Tag.Title = "my new title";
tfile.Save();
var tfile = TagLib.File.Create(@"C:\My audio.mp3");
string title = tfile.Tag.Title;
TimeSpan duration = tfile.Properties.Duration;
Console.WriteLine("Title: {0}, duration: {1}", title, duration);
// change title in the file
tfile.Tag.Title = "my new title";
tfile.Save();
var tfile = TagLib.File.Create(@"C:\My picture.jpg");
string title = tfile.Tag.Title;
var tag = tfile.Tag as TagLib.Image.CombinedImageTag;
DateTime? snapshot = tag.DateTime;
Console.WriteLine("Title: {0}, snapshot taken on {1}", title, snapshot);
// change title in the file
tfile.Tag.Title = "my new title";
tfile.Save();
var tfile = TagLib.File.Create(@"C:\My song.flac");
var custom = (TagLib.Ogg.XiphComment) tfile.GetTag(TagLib.TagTypes.Xiph);
// Read
string [] myfields = custom.GetField("MY_TAG");
Console.WriteLine("First MY_TAG entry: {0}", myfields[0]);
// Write
custom.SetField("MY_TAG", new string[] { "value1", "value2" });
custom.RemoveField("OTHER_FIELD");
rgFile.Save();
TagLib# is available on GitHub: https://github.com/mono/taglib-sharp
TagLib# is available on NuGet: https://www.nuget.org/packages/TagLibSharp
Install from package manager:
PM> Install-Package TagLibSharp -Version 2.3.0
git clone https://github.com/mono/taglib-sharp.git
cd taglib-sharp
dotnet build
dotnet test
You can open it in Visual Studio by using TaglibSharp.sln
Non exhaustive list of projects that use TagLib#:
And you, what do you use TagLib# for? Reply here
TagLib# is free/open source software, released under the LGPL. We welcome contributions! Please try to match our coding style, and include unit tests with any patches. Patches can be submitted by issuing a Pull Request (Git).