[Vorbis-dev] A few questions about libvorbis from a newbie

Gunter Königsmann gunter at peterpall.de
Tue Dec 1 23:08:55 PST 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512



On 02.12.2015 04:53, Blake Martin wrote:
> First off, I don't even know if this is the right place to ask
> these kind of questions, but I haven't been able to find answers
> anywhere else, so
> 
> 1. I have found that "pcmTotal * vorbisInfo->channels * 2" gives
> the uncompressed size of every ogg vorbis file I have used. What is
> a more robust way of getting the full uncompressed file size?
This sounds quite reliable. At least if the .ogg file is equipped with
the correct headers: If you capture the live stream from a radio
station that radio station won't know in advance how many samples you
will capture and pcmTotal (which is one of the first things you'll
get) won't be filled with the correct value.

Since ogg is vbr I assume the only way of working around bad headers
would be to decode the whole file and count the number of samples -
lest there is a way of querying every packet how many samples it
contains without actually decoding it.
> 
> 2. How do I read a certain amount of ms of data? For example, I
> have been using sizeUncompressed / seconds / 4 (using the above
> method to get sizeUncompressed) to try and get 250ms worth of data,
> but I'm not sure it is doing what I think it does.
Seems quite reasonable to me. You also can look up the seeking
mechanism of ogg vorbis that will allow you to move fast by a few
seconds. But this mechanism fails with many live streams - and it
might not get you to exactly the right point within the file you want
to be at.
> 
> 3. How do I determine the sample size of a file? For example, how
> do I know if I should reading 16 bit or 8 bit samples?
Ogg operates on floating-point numbers and is designed to do the best
job on the data format it gets - or is instructed to produce.
Unfortunately this means it doesn't care where the data came from and
how the data source looked like. Perhaps you could do some heuristics
trying to find out the remains of the typical noise generated by a
8-bit-sampling-process that are left after ogg-encoding the data. But
this approach needs loads of maths and won't be 100% reliable.

Kind regards,

     Gunter.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQJ8BAEBCgBmBQJWXpkHXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ1M0YwNDdDRTY2QjkxQjBGNzI0QzU0NUQ1
Qzg2QzBFNDIxMUQ1QjhFAAoJEFyGwOQhHVuOYTAP/17c3iD1R4lK3U7SLFyQDMSE
7TPwRlHp+Aijj9yUgDLF5rqg4fYzemPfzjixV9kyEcfQPVKyJLd011KJX75UpOFo
xnsCgmGMBhzYoX2PhJm+e4FlLnjzjOwYr7TuVQHswcng08YGO4ZKCIZay9rDlS4U
1YY8k5Ieove9RrWuTRXe6zBe15lWkQyRPbyXIzeoy7ODKqJxOr6B/C2+gkhw3+BF
b3KJFhT9adEblYvkqafYo6T5UQwmMkD7GvEAHs9zwk0MsftSnsif1rD2Yx3P3nTr
TamCOOyj/lItwZ0ZUvTn3eBhOrd0xzFejlhOs03njHTNgy2M1bH3cDbKG2wP5IVU
lxPIB4sImyNewcql2LLprrsfPtqRL0yn5i7Jo/B6b0qs3H9BUHQ7mw68KoM3/cTR
HZc7k6NI60CierFfVSa0YKXkONq2DB9JyQE71E+G2wPMwi+7IBBC7rPsp7h+jD7M
OszgwluVczWpc0O1UsAOHFfEM4WtqjqhYAAaMFlA5N5hDITw5JioqL1pI1FU3lSh
nq/eEVkSl8D4+datIexfV0jpNvsRv66rOQgkAOCCo3TfiEK8jhToJ7tliesLxpFK
CQKMZ8GW7QnOWH3L7tjXde4j2GSWx8T9dhtfGYBbkiimS3hscwbOxXsEhMFmmUiV
93iaRxPP/eFna4zcmbpP
=YU9/
-----END PGP SIGNATURE-----


More information about the Vorbis-dev mailing list