[Libav-user] Seeking problem with avformat_seek_file
moiein2000 at gmail.com
Tue Sep 13 18:49:14 CEST 2011
On Tue, Sep 13, 2011 at 12:42 PM, Benjamin Gretsch <libav at dndrunde.de>wrote:
> Good afternoon,
> After days of searching and trying, I still have a problem:
> When I use avformat_seek_file() to go back to the very beginning of a file
> and then av_read_frame(), I still don't get the first frames again.
> The goal is to extract multiple chunks of audio from a stream.
> My approach is to read the stream, discard what I don't need. While doing
> that I create a list of "points of interest" where I need to go back later.
> My intermediate approach is to always go back to the beginning and start
> discarding again.
> What I am doing exactly is:
> //read frames, discard what's not needed:
> while(...) av_read_frame(...)
> //go back to the beginning (that's the part that doesn't work):
> avcodec_flush_buffers(avcc); //flush the codec's buffers
> avf, streamIndex,
> bytepos, bytepos, bytepos,
> ); //bytepos is packet.pos of the first packet I have read
> //and will later be a position from the index that I will build
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.
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?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libav-user