<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">Op 16-12-14 om 00:00 schreef Neil
Hinnant:<br>
</div>
<blockquote
cite="mid:CAJF4+cE8LLCU34unKzNZ+e11pP7e_RTh-NArnKmzVAYQA-Ltbw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>1. Is it possible to know the total size of FLAC metadata
blocks in advance? Do I really need to parse all metadata
blocks until I see the METADATA_BLOCK_HEADER with
last-metadata-block == 1?<br>
</div>
</div>
</div>
</blockquote>
<br>
No and yes. You need to parse all<br>
<br>
<blockquote
cite="mid:CAJF4+cE8LLCU34unKzNZ+e11pP7e_RTh-NArnKmzVAYQA-Ltbw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>2. Is there a generally accepted best-practice for seeking
if there is no seektable present in the file? The format
states <i>"It is possible to seek to any given sample in a
FLAC stream without a seek table, but the delay can be
unpredictable since the bitrate may vary widely within a
stream." </i>Is this delay just a fact of life, or is there
any way to mitigate? <br>
</div>
</div>
</blockquote>
<br>
If you have a stream (without a seektable) of 30MB which encodes
music 4:00 long, and you want to seek to 2:00, the best guess is to
seek halfway the file. However, if the first part is silence and the
second part is noise, the 2:00 mark won't be halfway, but at the
beginning (because silence takes up much less space). This is what
is meant by the comment 'because the bitrate may vary wildly'<br>
<br>
So, the usual way is to take a reasonable guess, look for a frame,
read it's header and look for the framenumber. With the framenumber
known, it is clear where in the stream this first seek has gotten
you, and once more you can take a reasonable guess at where the
seekpoint should be, narrowing down the search range until you find
the frame with the sample that the seek was looking for.<br>
<br>
Seektables make this narrowing down much faster, but they aren't
strictly necessary.<br>
</body>
</html>