Stefan Oltmanns
2024-Oct-13 00:16 UTC
[flac-dev] C API: How to get a seektable for very long files?
Hello, I'm using flac to compress s signal data during capture. The sample rate is almost a thousands time higher compared to audio (40 MHz), resulting in a lot of data very quickly. I'm using the C API in my capturing application (mostly copy&paste directly from the example) and it works so far, but unfortunately for longer captures there is no seeking information. How can I tell flac to write seeking information? I assume it's not reserving enough space for the seek table (as a 2 hour capture at 40 MHz is almost 3 month at 40kHz (flac samplerate field is limited, so I set 40kHz)) and it won't rewrite a file that is several hundred GBs. I cannot find any clues in the documentation how to write a seektable/reserve space for it. Can someone help me out? Best regards Stefan
Martijn van Beurden
2024-Oct-13 19:00 UTC
[flac-dev] C API: How to get a seektable for very long files?
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