Click here to Skip to main content
Licence LGPL3
First Posted 25 Aug 2006
Views 52,240
Downloads 599
Bookmarked 54 times

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

By | 24 Apr 2009 | Article
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, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)

About the Author

Cyber Sinh



France France

Member

I am the developper of these freewares:
1. MetatOGGer
2. LyricWiki
3. Xiph Media Encoder

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionResizing jpg images PinmemberStefan Haglund22:33 28 Mar '12  
AnswerRe: Resizing jpg images PinmemberCyber Sinh23:56 28 Mar '12  
NewsProject move to Codeplex PinmemberCyber Sinh7:23 14 Dec '10  
Generalflac add cover to file Pinmemberrio1714:27 9 Feb '10  
GeneralRe: flac add cover to file PinmemberCyber Sinh4:40 9 Feb '10  
GeneralRe: flac add cover to file [modified] Pinmemberrio1715:03 9 Feb '10  
GeneralPlease Help PinmemberIamMike4Life6:57 7 Dec '09  
GeneralRe: Please Help PinmemberCyber Sinh7:12 7 Dec '09  
GeneralRe: Please Help PinmemberIamMike4Life13:16 30 Dec '09  
GeneralRe: Please Help PinmemberCyber Sinh14:04 30 Dec '09  
GeneralFragmenting Pages PinmemberKnuddlbaer15:21 22 Jun '08  
AnswerRe: Fragmenting Pages PinmemberCyber Sinh11:24 18 Jul '08  
GeneralRe: Fragmenting Pages PinmemberKnuddlbaer12:43 18 Jul '08  
GeneralRe: Fragmenting Pages PinmemberCyber Sinh5:31 25 Jul '08  
GeneralGreat, but there is a bug with small files PinmemberWorm23238:02 17 Mar '08  
NewsRe: Great, but there is a bug with small files PinmemberCyber Sinh11:47 17 Mar '08  
GeneralGood job Pinmember Dr.Luiji 9:30 3 Mar '08  
Thanks for sharing the code. I hope to use soon the SDK inside the site[^]
 
Good job Cyber i've give my 5 stars.
 
Dr.Luiji
 
Trust and you'll be trusted.

GeneralOggVorbis tag reading bug: splitting on = PinmemberGregor M15:11 13 Jul '07  
GeneralRe: OggVorbis tag reading bug: splitting on = PinmemberGregor M15:17 13 Jul '07  
AnswerRe: OggVorbis tag reading bug: splitting on = [modified] PinmemberCyber Sinh5:13 14 Jul '07  
GeneralIt looks really good but... Pinmemberwilliammorrishooper0:04 11 Mar '07  
AnswerRe: It looks really good but... PinmemberCyber Sinh1:30 11 Mar '07  
NewsRe: It looks really good but... PinmemberCyber Sinh5:12 14 Jul '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120529.1 | Last Updated 24 Apr 2009
Article Copyright 2006 by Cyber Sinh
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid