[Ffmpeg-devel] help on getting file offset from mpeg_decode_frame() in mpeg12.c

daniel.car at cox.net daniel.car
Fri Apr 27 01:42:59 CEST 2007


---- daniel.car at cox.net wrote: 
> I'm having a hard time tracing through the code.
> How do I print the current file offset from with in mpeg_decode_frame() in mpeg12.c?
> 
> I figure I need a pointer to struct ByteIOContext to print offset_t pos.  How do I get that pointer?  Is it possible from using a private data field in AVCodecContext *avctx or MpegEncContext *s2 ?
> 
> I'm currently using ffplay to interface to mpeg12.c  Is there an easier way to dump offsets with in a file of specific frames, slices, gop, etc...
> 

I was able to print the file offsets by dumping the offset into an unused variable in the AV codec context structure: timecode_frame_start

In ffplay.c video_thread() I added:
    is->video_st->codec->timecode_frame_start = is->ic->pb.pos;
In mpeg12.c mpeg_decode_frame() I added:
        buf_offset = buf_ptr - buf;
        file_pos = avctx->timecode_frame_start + buf_offset;

Then print the file_pos when I need to.  :-)

Thanks,
Daniel




More information about the ffmpeg-devel mailing list