[Ffmpeg-devel] Conveting Timecode to file Offset

Nitin nk.kashyap
Thu Sep 22 13:08:37 CEST 2005


Hi All,

I need to build an indexMap between PlayTime-inContent
and ByteOffset-inMedia(file)... 

i'm able to reach the desiered frame near a particular Timestamp
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;
}

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

kindly help asap....

Thanks & Regards
Nitin





More information about the ffmpeg-devel mailing list