[Ffmpeg-devel] av_seek_frame() units

Ian Gowen ian.gowen
Wed Jul 6 06:31:54 CEST 2005


While providing lots of useful info, this still doesn't address my original 
question: given the frame number, what is the formula to find the correct 
timestamp for a particular stream? (i.e. in AVStream.time_base units, not 
AV_TIME_BASE).

--Ian

On 7/5/05, Michael Niedermayer <michaelni at gmx.at> wrote:
> Hi
> 
> On Tuesday 05 July 2005 12:36, Andy Parkins wrote:
> > On Tuesday 2005 July 05 10:14, Michael Niedermayer wrote:
> > > > 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
> >
> > How's this?
> >
> >    MyPts = av_rescale( Packet.pts,
> >         AV_TIME_BASE * (int64_t) Stream->time_base.num,
> >         Stream->time_base.den );
> 
> looks good
> 
> [...]
> --
> Michael
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>





More information about the ffmpeg-devel mailing list