Click here to Skip to main content
6,630,586 members and growing! (16,282 online)
Email Password   helpLost your password?
Multimedia » Audio and Video » Audio     Intermediate License: The GNU Lesser General Public License

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

By Cyber Sinh

An article discussing an assembly that reads and writes Ogg tags
C# 2.0, Windows, .NET 2.0VS2005, Dev
Version:3 (See All)
Posted:25 Aug 2006
Updated:24 Apr 2009
Views:33,011
Bookmarked:48 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
9 votes for this article.
Popularity: 4.47 Rating: 4.68 out of 5

1

2
1 vote, 11.1%
3
1 vote, 11.1%
4
7 votes, 77.8%
5
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

About the Author

Cyber Sinh


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

Other popular Audio and Video articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 13 of 13 (Total in Forum: 13) (Refresh)FirstPrevNext
GeneralFragmenting Pages PinmemberKnuddlbaer16:21 22 Jun '08  
AnswerRe: Fragmenting Pages PinmemberCyber Sinh12:24 18 Jul '08  
GeneralRe: Fragmenting Pages PinmemberKnuddlbaer13:43 18 Jul '08  
GeneralRe: Fragmenting Pages PinmemberCyber Sinh6:31 25 Jul '08  
GeneralGreat, but there is a bug with small files PinmemberWorm23239:02 17 Mar '08  
NewsRe: Great, but there is a bug with small files PinmemberCyber Sinh12:47 17 Mar '08  
GeneralGood job Pinmember Dr.Luiji 10:30 3 Mar '08  
GeneralOggVorbis tag reading bug: splitting on = PinmemberGregor M16:11 13 Jul '07  
GeneralRe: OggVorbis tag reading bug: splitting on = PinmemberGregor M16:17 13 Jul '07  
AnswerRe: OggVorbis tag reading bug: splitting on = [modified] PinmemberCyber Sinh6:13 14 Jul '07  
GeneralIt looks really good but... Pinmemberwilliammorrishooper1:04 11 Mar '07  
AnswerRe: It looks really good but... PinmemberCyber Sinh2:30 11 Mar '07  
NewsRe: It looks really good but... PinmemberCyber Sinh6:12 14 Jul '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 24 Apr 2009
Editor: Deeksha Shenoy
Copyright 2006 by Cyber Sinh
Everything else Copyright © CodeProject, 1999-2009
Web19 | Advertise on the Code Project