[Ffmpeg-devel] av_seek_frame() units

Michael Niedermayer michaelni
Tue Jul 5 11:14:55 CEST 2005


On Tuesday 05 July 2005 10:17, Andy Parkins wrote:
> I don't know for sure is my answer.  However, I am having success treating
> the units to av_seek_frame() as being in AV_TIME_BASE units (at present
> this is a 64 bit integer representing time in microseconds passed
> AVFormatContext.start_time)

yes it uses AV_TIME_BASE units if no stream is specified, otherwise the 
timebase of the stream is used

> As to seeking to a particular (non-key) frame, I believe the suggestion
> from Rich Felker was that you seek to the nearest key frame using
> av_seek_frame() then enable hurry_up mode until you hit the frame you want.
> e.g. (error checking and initialisation ommitted)
> av_seek_frame( fmtCtx, -1, TARGET_PTS, AVSEEK_FLAG_BACKWARD );
> CodecCtx->hurry_up = 1;
> do {
>     av_read_frame( fmtCtx, &Packet );
>     // should really be checking that this is a video packet
>     MyPts = Packet.pts / Packet.duration *
> 	AV_TIME_BASE / av_q2d( Stream->r_frame_rate);

this is completely wrong, the division by Packet.duration makes no sens and 
its 1/Stream.time_base not Stream->r_frame_rate which should be used


More information about the ffmpeg-devel mailing list