Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Assembly to Read and Write Ogg Tags (Vorbis, FLAC and Speex)

0.00/5 (No votes)
24 Apr 2009 1  
An article discussing an assembly that reads and writes Ogg tags
Demo

Introduction

For my freeware project, MetatOGGer, I needed a managed library to read and write tags contained in Ogg and FLAC streams. As I couldn't find any, I decided to write one myself.

The codecs supported by this library include Vorbis, FLAC and Speex. Technical information about Ogg and FLAC files can also be gotten using this library.

Text tags will be stored in a SortedList<string, List<string>> because you can have several identical tags such as "artist," etc. Picture tags will be stored in a collection of ID3PictureFrame with a BitmapFrame property (Windows Imaging Component).

It's possible to read any raw data in an Ogg stream with the OggPageReader class.

Using the Code

The use of OggTagger and FlacTagger is very easy. The source code is fully documented (in French). Here is the diagram for main classes:

classes.png
using Luminescence.Xiph;
OggTagger ogg = new OggTagger(@"C:\Song.ogg");

// Load duration
DateTime time = new DateTime(0);
time = time.AddSeconds(ogg.Duration);

// Tags manipulation
string artist = ogg.Artist;
ogg.Title = "Creep";
SortedList<string, List<string>> tags = ogg.GetAllTags();
BitmapFrame cover = ogg.FlacArts[0].Picture;

History

  • 25 August, 2006 -- Original version 1.0 posted
  • 3 April, 2007 -- Article & downloads updated
  • 16 July, 2007 -- Article & downloads updated
  • 7 September, 2007 -- Source download, LuminescenceXiph.zip, updated as follows:
    • Tags of 255 more characters are now correctly managed in Ogg FLAC and Speex files
    • ClearNonOfficialTag() method doesn't throw exceptions
    • Vendor list has been updated to version 1.2 of libvorbis
    • An example application, MetatOGGer, is also provided in binary form
  • 24 January, 2008 -- Source download, LuminescenceXiph.zip, updated as follows:
    • The code contains a bug fix (an OutOfMemory exception could be thrown while reading some FLAC files)
    • The vendor tag for Vorbis has been updated for older and newer version of the codec
  • 29 March, 2008 -- Article & downloads updated as follows:
    • Fix a bug when reading very small Ogg files (<65KB).
  • 25 July, 2008 -- Major release (version 2.0), .NET 3.5 required
    • Heavy code refactoring (VorbisComment is now an abstract class)
    • New method CheckedVorbisCommentKey(string) in VorbisComment class
    • Fix a bug when reading or writing very big tags (>65 KB)
    • New classes : OggPage and OggPageReader for reading data in Ogg streams
    • Support of picture tags for native Flac or Ogg FLAC files (new class ID3PictureFrame)
    • Many other enhancements (vendor tag information updated, etc.)...
  • 22 April, 2009 -- Downloads updated
    • This version contains few code refactorings and one bug fix (in validation of vorbis comment key)

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here