[Libav-user] Seeking problem with avformat_seek_file

Benjamin Gretsch libav at dndrunde.de
Tue Sep 13 18:42:05 CEST 2011


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
avformat_seek_file(
	avf, streamIndex,
	bytepos, bytepos, bytepos, 	
	AVSEEK_FLAG_BYTE
); //bytepos is packet.pos of the first packet I have read
   //and will later be a position from the index that I will build

As it doesn't work as expected, I obviously am missing something vital. But
I can't find out what. Can somebody give a hint?

Thanks and best regards
Benjamin


More information about the Libav-user mailing list