Matthieu Regnauld
2018-10-26 13:28:03 UTC
Hello,
I try to understand how I can seek in an audio file, at a very precise
position.
For example, I want to set the current position in my file to the frame
#1234567 (in a file encoded at 44100 Hz), which is equivalent to seek at
27994.717 milliseconds.
To achieve that, I tried this:
av_seek_frame(formatContext, audio_stream_index, 1234567,
AVSEEK_FLAG_FRAME);
But for some reason, the positioning is not totally accurate in an OGG file
(there is a delay of about 1/4 second), and not accurate at all in an MP3
file (I stay close to the beginning of the file...).
Here is my code:
https://gist.github.com/mregnauld/2538d98308ad57eb75cfcd36aab5099a
Do I use the function the right way, or even the right function?
Thanks for your help.
I try to understand how I can seek in an audio file, at a very precise
position.
For example, I want to set the current position in my file to the frame
#1234567 (in a file encoded at 44100 Hz), which is equivalent to seek at
27994.717 milliseconds.
To achieve that, I tried this:
av_seek_frame(formatContext, audio_stream_index, 1234567,
AVSEEK_FLAG_FRAME);
But for some reason, the positioning is not totally accurate in an OGG file
(there is a delay of about 1/4 second), and not accurate at all in an MP3
file (I stay close to the beginning of the file...).
Here is my code:
https://gist.github.com/mregnauld/2538d98308ad57eb75cfcd36aab5099a
Do I use the function the right way, or even the right function?
Thanks for your help.