<br><div class="gmail_quote">On Tue, Sep 13, 2011 at 12:42 PM, Benjamin Gretsch <span dir="ltr"><<a href="mailto:libav@dndrunde.de">libav@dndrunde.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Good afternoon,<br>
<br>
After days of searching and trying, I still have a problem:<br>
<br>
When I use avformat_seek_file() to go back to the very beginning of a file<br>
and then av_read_frame(), I still don't get the first frames again.<br>
<br>
The goal is to extract multiple chunks of audio from a stream.<br>
My approach is to read the stream, discard what I don't need. While doing<br>
that I create a list of "points of interest" where I need to go back later.<br>
<br>
My intermediate approach is to always go back to the beginning and start<br>
discarding again.<br>
What I am doing exactly is:<br>
<br>
<br>
//read frames, discard what's not needed:<br>
while(...) av_read_frame(...)<br>
<br>
//go back to the beginning (that's the part that doesn't work):<br>
avcodec_flush_buffers(avcc); //flush the codec's buffers<br>
avformat_seek_file(<br>
        avf, streamIndex,<br>
        bytepos, bytepos, bytepos,<br>
        AVSEEK_FLAG_BYTE<br>
); //bytepos is packet.pos of the first packet I have read<br>
   //and will later be a position from the index that I will build<br></blockquote><div> </div></div>Have you tried moving the flush after the seek (not sure if that will make a difference). Here's how I use it, without any problem: avformat_seek_file(m_pFormatCtx, m_nVideoStream, INT64_MIN, nTime, INT64_MAX, 0), where nTime would be zero. This is how it'd done (min/max) in in one of the ffmpeg.c or ffplay.c files.<br>

<br>If you have an example file I can try it and see if I also have that issue. Which type of file are you using btw?<br><br>Matt<br>