[Ffmpeg-devel] How to retrieve audio or video stream at same timestamp using av_read_frame

Martin Boehme boehme
Mon May 23 11:55:34 CEST 2005

Michel Bardiaux wrote:
> Martin Boehme wrote:
>> Keith Mok wrote:
>>> If buffer excess data, will require a lot of memory specially if you 
>>> need to buffer several seconds of the video data in a frame rate of 
>>> 30 fps.
>>> Any comment?
>> Yes, it's going to require some memory... but what else could you do?
> av_seek_frame and av_read_frame should work independently on each stream.

Really? av_seek_frame() does have a "stream" parameter, but AFAICT that 
just specifies the stream you want to use as an timebase. The end of 
av_seek_frame_generic() (for example) goes like this:

     url_fseek(&s->pb, ie->pos, SEEK_SET);

     av_update_cur_dts(s, st, ie->timestamp);

And av_update_cur_dts() then does this:

     for(i = 0; i < s->nb_streams; i++) {
         AVStream *st = s->streams[i];

         st->cur_dts = av_rescale(timestamp,
             st->time_base.den *
             st->time_base.num *

(Reformatted for 72 characters.)

And even if av_seek_frame() did seek streams independently, that would 
just shift the burden of buffering frames to the disk cache or (worse) 
cause the disk to thrash... Keith seems to be doing the equivalent of 
seeking frames independently by using two different AVFormatContexts on 
the same file, which (for the above reason) is not a good idea IMO.


Martin B?hme
Inst. f. Neuro- and Bioinformatics
Ratzeburger Allee 160, D-23538 Luebeck
Phone: +49 451 500 5514
Fax:   +49 451 500 5502
boehme at inb.uni-luebeck.de

More information about the ffmpeg-devel mailing list