[flac-dev] C API: How to get a seektable for very long files?

Martijn van Beurden mvanb1 at gmail.com
Sun Oct 13 19:00:38 UTC 2024


Op zo 13 okt 2024 om 02:16 schreef Stefan Oltmanns <stefan-oltmanns at gmx.net>:
>
> I cannot find any clues in the documentation how to write a
> seektable/reserve space for it.
> Can someone help me out?
>

There's actually quite a lot of documentation for this.

Please review https://xiph.org/flac/api/group__flac__stream__encoder.html#ga80d57f9069e354cbf1a15a3e3ad9ca78

I quote:
> SEEKTABLE blocks are handled specially. Since you will not know the
> values for the seek point stream offsets, you should pass in a
> SEEKTABLE 'template', that is, a SEEKTABLE object with the required
> sample numbers (or placeholder points), with 0 for the frame_samples
> and stream_offset fields for each point. If the client has specified
> that it supports seeking by providing a seek callback to
> FLAC__stream_encoder_init_stream() or both seek AND read callback to
> FLAC__stream_encoder_init_ogg_stream() (or by using
> FLAC__stream_encoder_init*_file() or
> FLAC__stream_encoder_init*_FILE()), then while it is encoding the
> encoder will fill the stream offsets in for you and when encoding is
> finished, it will seek back and write the real values into the
> SEEKTABLE block in the stream. There are helper routines for
> manipulating seektable template blocks; see metadata.h:
> FLAC__metadata_object_seektable_template_*(). If the client does not
> support seeking, the SEEKTABLE will have inaccurate offsets which will
> slow down or remove the ability to seek in the FLAC stream.


Also, take a look at this:
https://xiph.org/flac/api/group__flac__metadata__object.html#gab91c8b020a1da37d7524051ae82328cb

Hope that helps.

Also, as I'm always extra curious when FLAC is used for non-audio
purposes: could you perhaps say a little bit about what kind of
signals you're compressing?

Kind regards,

Martijn van Beurden


More information about the flac-dev mailing list