Discussion:
[Libav-user] Inaccurate position in ogg audio file
Matthieu Regnauld
2018-10-29 11:51:42 UTC
Permalink
Hello,

When I extract samples from an audio file, or when I seek in an audio file,
I can see exactly where I am, thanks to the following code:

// position in microseconds:
1000000 * (packet.pts * ((float) stream->time_base.num /
stream->time_base.den))

It works great with mp3 files, but it's sometimes not accurate with ogg
files: sometimes, the position I get is approximately 10 ms in advance
(actually 448 samples in advance).
It appears that sometimes, for ogg files only, packet.pts (and packet.dts
too) is a bit in advance, and then, gets back to normal after a couple of
extractions.
Also, I don't know if it's related, but with ogg files, I also get a lot of
AVERROR(EAGAIN).

Here is my code:
https://gist.github.com/mregnauld/2538d98308ad57eb75cfcd36aab5099a

Do you know where it comes from and maybe, how to fix it?

Thanks for your help.

Loading...