[Flac-dev] reading vorbis comments with FLAC++?
Joshua Haberman
joshua at haberman.com
Sun Nov 9 23:21:04 PST 2003
On Fri, 2003-11-07 at 22:56, Joshua Kwan wrote:
> Well, I'm quite frankly stumped. I'm writing a program that recurses
> into directories and reads (among others) FLAC files and should be able
> to read the vorbis comments ARTIST and TITLE from the file.
>
> A while back, I was popen()ing to metaflac, because I didn't want to
> mess with libFLAC. But now, it's the weekend, so I can mess around with
> this. Here's the code in question:
>
> bool getflac (struct Song* flac, const char* path)
> {
> FLAC__StreamMetadata *md = FLAC__metadata_object_new (FLAC__METADATA_TYPE_STREAMINFO);
>
> if (FLAC__metadata_get_streaminfo(path, md))
> {
> unsigned nc = 0, i;
> FLAC::Metadata::VorbisComment vc (md);
There are several different types of metadata blocks: you have obtained
the STREAMINFO block and tried to treat it like a VORBISCOMMENT block by
passing it to the VorbisComment constructor. You will need to iterate
through the metadata blocks until you find a VORBISCOMMENT block. See
http://flac.sourceforge.net/format.html for more information about the
format, and more detail on the different kinds of metadata blocks.
I have not used the C++ interface, but I think this is your problem.
For an example of reading vorbiscomments from a FLAC file, you can see
my vorbiscomment support for Rhythmbox. It uses the C interface,
though, and uses the stream decoder instead of the metadata iterator
interface (this is so it can support streams in addition to files):
http://cvs.gnome.org/lxr/source/rhythmbox/monkey-media/stream-info-impl/flac-stream-info-impl.c
See FLAC_stream_info_impl_open_stream() and FLAC_metadata_callback().
Josh
More information about the Flac-dev
mailing list