[Flac] Application Metadata

Josh Coalson xflac at yahoo.com
Mon Aug 8 13:45:22 PDT 2005

--- Paul <elegant_dice at yahoo.com> wrote:
> Hi,
> I'm sorry to say that I've found the libFLAC++ interface and 
> documentation pretty slim and baffling.

yes, libFLAC++ is just a thin wrapper around libFLAC.  if you
follow the api links down into the libFLAC equivalent, there is
much more info.  e.g. starting at


for the C++ FLAC::Encoder::File docs, follow the link into the
libFLAC file encoder module

hit the link for FLAC__file_encoder_set_metadata
and follow the inheritance link to
to FLAC__stream_encoder_set_metadata()

I don't really know any other way to do the docs without duplicating
a lot of info in several places.

> What I need to do is add some application-specific metadata to a FLAC
> file (i'm using the FLAC++ fileencoder).  It is currently just a
> string of characters, which doesn't need to be null-terminated.

that is the way if you are adding the metadata while encoding to
FLAC.  if you want to add metadata to an existing FLAC file you
should use one of the iterator interfaces, not the encoder.

> Based on some of the test code, I had assumed I would do something
> like:
> FLAC::Metadata::Application header_flac;
> FLAC__byte header_flac_id[4] = { 1, 2, 3, 4 };
> header_flac.set_id(header_flac_id);
> // set the metadata
> FLAC::Metadata::Prototype *metadata_sequence[] = { &header_flac };
> // and now i continue to init(), process_interleaved() and finish()
> But that kept giving me segmentation faults.

that looks fine, can you send the backtrace?

> So I tried the following, 
> and it still gave me segmentation faults.
> FLAC__byte header_flac_id[4] = { 1, 2, 3, 4 };
> FLAC__byte * header_byte = new FLAC__byte[header_str.size()];
> copy(header_str.begin(),header_str.end(),header_byte);
> // set the metadata
> FLAC::Metadata::Application * header_flac = new
> FLAC::Metadata::Application;
> header_flac->set_id(header_flac_id);
> header_flac->set_data(header_byte,header_str.size());
> FLAC::Metadata::Prototype **metadata_sequence = new 
> (FLAC::Metadata::Prototype*)[1];
> metadata_sequence[0] = header_flac;
> cnc.set_metadata(metadata_sequence,1);
> // and now i continue to init(), process_interleaved() and finish()

that looks fine too but shouldn't be necessary, as the first
version should work.


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the Flac mailing list