<div dir="ltr"><div class="gmail_quote"><div dir="ltr"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div dir="ltr" class="m_-3519073807975886573m_7914421609640037261gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div>Hello,</div><div><br></div><div>I try to understand how I can seek in an audio file, at a very precise position.</div><div><br></div><div>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.</div><div><br></div><div>To achieve that, I tried this:</div><div><br></div><div> <span class="m_-3519073807975886573m_7914421609640037261gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap">av_seek_frame</span><span style="color:rgb(36,41,46);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;white-space:pre-wrap">(formatContext, audio_stream_index, 1234567, AVSEEK_FLAG_FRAME);</span></div><div><br></div><div>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...).</div><div><br></div><div>Here is my code: <a href="https://gist.github.com/mregnauld/2538d98308ad57eb75cfcd36aab5099a" target="_blank">https://gist.github.com/mregnauld/2538d98308ad57eb75cfcd36aab5099a</a></div><div><br></div><div>Do I use the function the right way, or even the right function?</div><div><br></div><div>Thanks for your help.</div></div><div><br></div></div></div></div></div>
_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a></blockquote><div><br></div><div>Did you read description of av_seek_frame? The parameter is in time_base units.</div><div>Audio frame is codec internal property and generally meaningless, I think you take it wrong.</div><div>If you want very precise relative to video stream frame, this is quite complex. You need to consider relative stream offsets. Also there may be audio decoder delay.</div><div>Hope this helps.</div><div><br></div></div></div>