[Flac-dev] Updating metadata while encoding

Olivier Guilyardi list at samalyse.com
Thu Jun 3 04:58:26 PDT 2010


On 05/28/2010 04:38 PM, Olivier Guilyardi wrote:
> Hi,
> 
> I am working on an application which records directly into a FLAC file. For this
> purpose I'm using the FLAC stream encoder interface.
> 
> It works fine, but if my application is killed during encoding, the metadata is
> not being updated since the file isn't closed properly by calling
> FLAC__stream_encoder_finish().
> 
> Thus when opening the file afterwards for playback, it is possible to decode
> audio data but the FLAC__StreamMetadata.data.stream_info.total_samples field is
> equals to zero.
> 
> This is a true problem because it looks like data loss to the user, especially
> if he/she's been recording for hours...
> 
> So I'm looking for a way to update the metadata periodically during encoding,
> before calling FLAC__stream_encoder_finish().
> 
> Is this possible?

For the records, I ended up with adding FLAC__stream_encoder_flush(), as shown
in the attached diff.

It's certainly not perfect, for instance it won't work for the OGG container.

But it apparently works for me.

--
  Olivier
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: encoder_flush.diff
Url: http://lists.xiph.org/pipermail/flac-dev/attachments/20100603/0f30f265/attachment.txt 


More information about the Flac-dev mailing list