[Ffmpeg-devel] Re: av_seek_frame() units

Nitin nk.kashyap
Thu Sep 22 12:36:59 CEST 2005


Andy Parkins <andyparkins <at> gmail.com> writes:

> 
> On Wednesday 2005 July 06 14:27, Steve Willis wrote:
> 
> > Let's say I want to seek to a frame that is 14.25 seconds into a stream.
> > Would someone please post actual code showing (1) how to calculate the
> > value for 14.25 seconds to pass to av_seek_frame to seek to the nearest
> > key frame (Ian's question), and (2) a recommended way to actually seek
> > to the precise frame for 14.25 seconds, regardless of whether it is a
> > keyframe (my question).




I Get wat you are trying to say here, to an extent it works also...
as an extention to this i need to build and indexMap between PlayTime-inContent
and ByteOffset-inMedia(file)... 
with the method explained earlier i'm able to reach the desiered frame or
somewhr near it... thats okay... but, i'm finding it difficult to convert that
TimeCode into ByteOffset in mpeg File...

i tried this...

if( seekRequested ) {
     TARGET_PTS = 14.25 * AV_TIME_BASE;
     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 = av_rescale( Packet.pts,
             AV_TIME_BASE * (int64_t) Stream->time_base.num,
             Stream->time_base.den );
         // Once we pass the target point, break from the loop
         if( MyPts >= TARGET_PTS )
             break;

         // This is whr i find problem
         timeStamp += TIME_JUMP;
         grabOffset = url_ftell( &fmtCtx->pb );

         /*add this offset to index table*/
         AddIndexEntry( &MainIDX, TARGET_PTS, grabOffset);
         
         av_free_packet( &Packet );
    } while(1);
    CodecCtx->hurry_up = 0;
}

but the problem is tht api: url_ftell allways return 0... and not hte offset i'm
interested in...
also another observation was that the Pos value inside fmtCtx->pb
(ByteIOContext) is changing...

kindly help asap....

Thanks & Regards
Nitin






More information about the ffmpeg-devel mailing list