assuming you are going trough the files AVPackets and you have the total  
duration from formatContext->duration, you just need to multiply the  
packets packet->pts by the packet stream->timebase and you get the  
position (in relation to display time) of the file.
so, yeah exactly what you said.

On Mon, 12 Jan 2009 17:18:29 -0000, Marc Mason <[email protected]> wrote:

> Hello,
>
> I'm using libavformat to demux multimedia files (only AVI and MPEG Audio
> at the moment).
>
> I need to write a function returning the current position in the file,
> in milliseconds. Another thread might call such a function periodically
> to display a time bar informing the user "where" he is in the file.
>
> What's the best way to do this?
>
> I suppose I can use the PTS field in AVPacket :
>
> Every time I read a new frame with av_read_frame, I'd compute an actual
> time using pkt.pts and formatctx->streams[pkt.stream_index]->time_base,
> and store the result in some static global variable which I return when
> another thread wants to know "what time it is" ?
>
> Is there a better way ? (Is the info perhaps already available elsewhere
> in the AVFormatContext ?)
>


_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to